diff --git a/CHANGELOG.md b/CHANGELOG.md index c6e3ae8..15d2116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Common and useful classes, methods, exceptions etc. 4. Travis CI > run many tasks using Phing (instead of PHPUnit only) 5. Fix integration with [Coveralls](https://www.coveralls.io) (available as the badge in [README.md](README.md)) 6. Implement [PHPStan](https://github.com/phpstan/phpstan) +7. PHPUnit > execute tests in random order # 1.0.1 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a8faf74..b6e693d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,12 @@ - + diff --git a/tests/Collection/CollectionTest.php b/tests/Collection/CollectionTest.php index 092ef89..5c5112a 100644 --- a/tests/Collection/CollectionTest.php +++ b/tests/Collection/CollectionTest.php @@ -347,27 +347,30 @@ class CollectionTest extends BaseTestCase */ public function provideElementToAdd() { - $collection = new Collection(); - yield[ - 'test1', + 'This is test 1', 1, 0, - $collection, + new Collection(), ]; yield[ - 'test2', + 'This is test 2', 2, 1, - $collection, + new Collection([ + 'I am 1st', + ]), ]; yield[ - 'test3', + 'This is test 3', 3, 2, - $collection, + new Collection([ + 'I am 1st', + 'I am 2nd', + ]), ]; } @@ -378,46 +381,58 @@ class CollectionTest extends BaseTestCase */ public function provideElementToAddWithIndex() { - $collection = new Collection(); - yield[ + 'This is test 1', 'test1', - 'aa', 1, - 'aa', - $collection, + 'test1', + new Collection(), ]; yield[ + 'This is test 2', 'test2', - 'oo', 2, - 'oo', - $collection, + 'test2', + new Collection([ + 'test1' => 'I am 1st', + ]), ]; yield[ - 'test3', + 'This is test 3', null, 3, 0, - $collection, + new Collection([ + 'test1' => 'I am 1st', + 'test2' => 'I am 2nd', + ]), ]; yield[ - 'test4', + 'This is test 4', '', 4, 1, - $collection, + new Collection([ + 'test1' => 'I am 1st', + 'test2' => 'I am 2nd', + 'I am 3rd', + ]), ]; yield[ + 'This is test 5', 'test5', - 'vv', 5, - 'vv', - $collection, + 'test5', + new Collection([ + 'test1' => 'I am 1st', + 'test2' => 'I am 2nd', + 2 => 'I am 3rd', + 3 => 'I am 4th', + ]), ]; } diff --git a/tests/Utilities/UriTest.php b/tests/Utilities/UriTest.php index 20b1eaf..6f92391 100644 --- a/tests/Utilities/UriTest.php +++ b/tests/Utilities/UriTest.php @@ -60,6 +60,15 @@ class UriTest extends BaseTestCase */ public function testReplenishProtocol($expected, $url, $protocol = '') { + /* + * Required to get protocol when it's not provided and to void test failure: + * + * Failed asserting that two strings are identical. + * Expected :'://test' + * Actual :'http://test' + */ + $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; + self::assertSame($expected, Uri::replenishProtocol($url, $protocol)); } @@ -251,7 +260,7 @@ class UriTest extends BaseTestCase public function provideUrlToReplenishProtocol() { yield[ - '://test', + 'http://test', 'test', '', ];