Currently, there are a lot of tests which follow a pattern along the lines of:
// Do something
$this->assertSame($expected, $result['key']['subkey']->property);
Tests like these are unstable as they may error out on any of the following:
$result not being an array.
- The
'key' index not existing in $result
- The
'subkey' index not existing in $result['key']
$result['key']['subkey'] not being an object
$result['key']['subkey'] not being an object of the expected type (instance of)
- The object in
$result['key']['subkey'] not having a property named $property.
Those tests should be stabilized and improved by changing them to something along the lines of:
// Do something
$this->assertIsArray($result);
$this->assertHaskey('key', $result);
$this->assertIsArray($result['key']);
$this->assertHaskey('subkey', $result['key']);
$this->assertIsObject($result['key']['subkey']);
$this->assertInstanceOf($classname, $result['key']['subkey']);
$this->assertHasAttribute('property', $result['key']['subkey']);
$this->assertSame($expected, $result['key']['subkey']->property);
Additionally, all tests which have multiple assertions, should pass the $message parameter to each assertion to help figure out which assertion has failed when a test fails.
Other review tasks (optional, but highly recommended)
- Refactoring tests methods which do the same thing to data providers.
- Enhancing existing data providers to use named data sets and keyed data entries.
- Adding appropriate
@covers tags.
- Reviewing code coverage and adding additional tests to raise (both path as well as branch) code coverage.
- Adding test documentation.
- Potentially splitting test classes which do too much into multiple classes based on what is being covered by the tests.
Actions list
Currently, there are a lot of tests which follow a pattern along the lines of:
Tests like these are unstable as they may error out on any of the following:
$resultnot being an array.'key'index not existing in$result'subkey'index not existing in$result['key']$result['key']['subkey']not being an object$result['key']['subkey']not being an object of the expected type (instance of)$result['key']['subkey']not having a property named$property.Those tests should be stabilized and improved by changing them to something along the lines of:
Additionally, all tests which have multiple assertions, should pass the
$messageparameter to each assertion to help figure out which assertion has failed when a test fails.Other review tasks (optional, but highly recommended)
@coverstags.Actions list
Requests\Tests\ChunkedEncodingTest- PR ChunkedEncodingTest: improve tests #581Requests\Tests\CookiesTest- PR series, PR Cookie\UriMatchesTest: improve and stabilize #737Owner: @jrfnl
Status: Ready, waiting to be pulled
Requests\Tests\EncodingTest- PR DecompressionTest: improve tests #595Requests\Tests\IdnaEncoderTest- PR IdnaEncoderTest: improve tests #549Requests\Tests\IriTestRequests\Tests\RequestsTestRequests\Tests\SessionTestOwner: @jrfnl
Status: WIP
Requests\Tests\SslTest- PR Ssl: improve tests #551Requests\Tests\Auth\BasicTest- PR Auth\Basic: improve tests #557Requests\Tests\Cookie\JarTest- PR Cookie\Jar tests: stabilize and improve #734Requests\Tests\Proxy\HttpTestRequests\Tests\Response\HeadersTest- PR Response\Headers: improve tests #555Requests\Tests\Transport\BaseTestCaseRequests\Tests\Transport\CurlTestRequests\Tests\Transport\FsockopenTestRequests\Tests\Utility\FilteredIteratorTest- PR FilteredIteratorTest: improve tests #550Status: basic review done, could use more improvements and additional tests.