Repository navigation
Conversation
5f28c51 to
ba9499d
Compare
33058d6 to
f2f2a05
Compare
This will allow the tests to work offline or if the servers have an outage, and they will not break if the site changes.
f2f2a05 to
5813cbc
Compare
|
Re: the discussion from https://chat.indieweb.org/microformats/2026-11-09
For tests, you do not want to specify a port number, since you have no way of knowing which ports are free. But the extension will only be needed for development and developers can easily install it when missing from their environment. We already use
That does appear to work: $curlExec = $this->getFunctionMock('Mf2', 'curl_exec');
$curlExec
->expects($this->exactly(2))
->willReturn(
file_get_contents(__DIR__ . '/waterpigs.co.uk_index.html'),
file_get_contents(__DIR__ . '/waterpigs.co.uk_photo.jpg')
);
$curlGetinfo = $this->getFunctionMock('Mf2', 'curl_getinfo');
$curlGetinfo
->expects($this->exactly(2))
->willReturn(
['content_type' => 'text/html', 'url' => 'http://waterpigs.co.uk/'],
['content_type' => 'image/jpeg', 'url' => 'http://waterpigs.co.uk/photo.jpg']
);Though I find replacing random functions called internally by the system under test far less elegant than using it as is and controlling the inputs.
At least Arch, Debian, Fedora and NixOS all include And since tests will only be run by developers/CI, they can easily install it, if they use a stripped down environment for development for some reason.
Running Detailsphp-mf2 $ composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires donatj/mock-webserver ^2.10 -> satisfiable by donatj/mock-webserver[v2.10.0, v2.10.1].
- donatj/mock-webserver[v2.10.0, ..., v2.10.1] require ext-sockets * -> it is missing from your system. Install or enable PHP's sockets extension.
To enable extensions, verify that they are enabled in your .ini files:
- /nix/store/bbbcw1zff9dmqkdwffvhghww4ysci23c-php-with-extensions-8.5.12/lib/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-sockets` to temporarily ignore these required extensions.If the user decides to override it with But again, this should not be an obstacle in practice.
Am I missing some use case where you would want to run tests and be unable to install the extension?
I previously wrote a small wrapper around the built-in PHP server. Then we found
Please no more increasing dependency on GitHub. We should be striving to build Indie Web, not being beholden to corporations. Especially when GitHub is has been increasingly unreliable lately. I develop software from my local checkout, benefitting from git being decentralized VCS. So, as long as I obtained dependencies prior to GitHub crumbling, I can continue to run tests just fine. |
75e92d6 to
5813cbc
Compare
|
I tried to move this PR to the top of the stack but that would cause The website used by the test changed again, now it passes I could update the test again but this PR solves it once and for all in better way IMO so I moved it back to the bottom. |
This will allow the tests to work offline or if the servers have an outage,
and they will not break if the site changes.
Part of PR stack:
/..#297