From aed9f32e0481563615329818bd875ca99e123769 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 21 Jan 2019 20:17:54 -0800 Subject: [PATCH] tests: Remove use of $IP and MediaWikiTestCase in libs/composer tests Reference the fixture files relatively instead of absolutely, this is done for most other references to data files as well I believe. Use plain arrayEquals(), which seems to suffice here. In PHP 7 at least, regular == doesn't require the declaration order of the keys to be the same in order to evaluate to true. Change-Id: Iddc874ec811f5c960e13d480d70bcb20334cfa1e --- .../includes/libs/composer/ComposerInstalledTest.php | 9 ++++----- .../includes/libs/composer/ComposerJsonTest.php | 11 +++++------ .../includes/libs/composer/ComposerLockTest.php | 9 ++++----- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php b/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php index 05ae2a377b..58e617ca82 100644 --- a/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerInstalledTest.php @@ -1,13 +1,12 @@ installed = "$IP/tests/phpunit/data/composer/installed.json"; + $this->installed = __DIR__ . "/../../../data/composer/installed.json"; } /** @@ -16,7 +15,7 @@ class ComposerInstalledTest extends MediaWikiTestCase { */ public function testGetInstalledDependencies() { $installed = new ComposerInstalled( $this->installed ); - $this->assertArrayEquals( [ + $this->assertEquals( [ 'leafo/lessphp' => [ 'version' => '0.5.0', 'type' => 'library', @@ -494,6 +493,6 @@ class ComposerInstalledTest extends MediaWikiTestCase { ], 'description' => 'The PHP Unit Testing framework.', ], - ], $installed->getInstalledDependencies(), false, true ); + ], $installed->getInstalledDependencies() ); } } diff --git a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php index ded5f8fe09..720fa6e8fd 100644 --- a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php @@ -1,14 +1,13 @@ json = "$IP/tests/phpunit/data/composer/composer.json"; - $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json"; + $this->json = __DIR__ . "/../../../data/composer/composer.json"; + $this->json2 = __DIR__ . "/../../../data/composer/new-composer.json"; } /** @@ -17,12 +16,12 @@ class ComposerJsonTest extends MediaWikiTestCase { */ public function testGetRequiredDependencies() { $json = new ComposerJson( $this->json ); - $this->assertArrayEquals( [ + $this->assertEquals( [ 'cdb/cdb' => '1.0.0', 'cssjanus/cssjanus' => '1.1.1', 'leafo/lessphp' => '0.5.0', 'psr/log' => '1.0.0', - ], $json->getRequiredDependencies(), false, true ); + ], $json->getRequiredDependencies() ); } public static function provideNormalizeVersion() { diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php index c7654388df..f5fcdbe018 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -1,13 +1,12 @@ lock = "$IP/tests/phpunit/data/composer/composer.lock"; + $this->lock = __DIR__ . "/../../../data/composer/composer.lock"; } /** @@ -16,7 +15,7 @@ class ComposerLockTest extends MediaWikiTestCase { */ public function testGetInstalledDependencies() { $lock = new ComposerLock( $this->lock ); - $this->assertArrayEquals( [ + $this->assertEquals( [ 'wikimedia/cdb' => [ 'version' => '1.0.1', 'type' => 'library', @@ -115,7 +114,7 @@ class ComposerLockTest extends MediaWikiTestCase { 'and configure its support in an easy way. ' . 'Main features are language selection, input methods and web fonts.', ], - ], $lock->getInstalledDependencies(), false, true ); + ], $lock->getInstalledDependencies() ); } } -- 2.20.1