tests: Remove use of $IP and MediaWikiTestCase in libs/composer tests
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 22 Jan 2019 04:17:54 +0000 (20:17 -0800)
committerNikerabbit <niklas.laxstrom@gmail.com>
Tue, 22 Jan 2019 08:01:36 +0000 (08:01 +0000)
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

tests/phpunit/includes/libs/composer/ComposerInstalledTest.php
tests/phpunit/includes/libs/composer/ComposerJsonTest.php
tests/phpunit/includes/libs/composer/ComposerLockTest.php

index 05ae2a3..58e617c 100644 (file)
@@ -1,13 +1,12 @@
 <?php
 
-class ComposerInstalledTest extends MediaWikiTestCase {
+class ComposerInstalledTest extends PHPUnit\Framework\TestCase {
 
        private $installed;
 
        public function setUp() {
                parent::setUp();
-               global $IP;
-               $this->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() );
        }
 }
index ded5f8f..720fa6e 100644 (file)
@@ -1,14 +1,13 @@
 <?php
 
-class ComposerJsonTest extends MediaWikiTestCase {
+class ComposerJsonTest extends PHPUnit\Framework\TestCase {
 
        private $json, $json2;
 
        public function setUp() {
                parent::setUp();
-               global $IP;
-               $this->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() {
index c765438..f5fcdbe 100644 (file)
@@ -1,13 +1,12 @@
 <?php
 
-class ComposerLockTest extends MediaWikiTestCase {
+class ComposerLockTest extends PHPUnit\Framework\TestCase {
 
        private $lock;
 
        public function setUp() {
                parent::setUp();
-               global $IP;
-               $this->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() );
        }
 
 }