Page MenuHomePhabricator

Make newinternal tests work even if there is no internet connectivity
Closed, ResolvedPublic


Currently, there are two places where tests query the API. We should hard-code responses using mocking to prevent this, per good test practice. Example log with internet disabled:

Traveler:waca Matthew$ /Applications/XAMPP/xamppfiles/bin/php ~/phpunit-4.5.0.phar 
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.

Configuration read from /Applications/XAMPP/xamppfiles/htdocs/waca/phpunit.xml.dist

F....E.............................................I....E........ 65 / 92 ( 70%)

Time: 276 ms, Memory: 7.75Mb

There were 2 errors:

1) Waca\Tests\IdentificationVerifierTest::testApiReturnsExpectedResults
Waca\Exceptions\CurlException: Remote request failed with error Failed to connect to Host is down


2) Waca\Tests\Validation\RequestValidationHelperTest::testValidateGoodName
file_get_contents( failed to open stream: Host is down



There was 1 failure:

1) Warning
No tests found in class "CountActionTest".
Tests: 92, Assertions: 273, Failures: 1, Errors: 2, Incomplete: 3.

(Ignore "CountActionTest" failure, I was implementing that test at the time I saved this log)

Event Timeline

stwalkerster claimed this task.
stwalkerster triaged this task as Normal priority.
stwalkerster added a subscriber: stwalkerster.

@matthewrbowker - I "fixed" the ID verifier test by making it skip when it can't contact meta; I'm hesitant to mock out the web request since I want to make sure that this code can deal with the potentially changing page on meta.

I know this is technically an integration test that we should be running with an integration test suite, but until we get a couple more "unit" tests that are actually integration tests, we might as well keep them as special cases here.

RequestValidationHelperTest::testValidateGoodName doesn't exist in my branch, so I suspect this is one of the tests you've added, or a test I've removed and forgotten about - we should probably sync up at some point soon.