From: Thiemo Kreuz Date: Mon, 30 Sep 2019 14:20:34 +0000 (+0200) Subject: tests: Replace assertions on count() == 0 with strict === [] X-Git-Tag: 1.34.0-rc.0~47^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=cff596804a6582bf637b4bc28abc8d75d1e4d7f9 tests: Replace assertions on count() == 0 with strict === [] The benefit of using count() is that the test would still succeed if the return vfalue is not an array, but an iterable object. It seems this is not needed. Change-Id: I23529f6990aebe0cce86e236a21820fe74993204 --- diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php index 24d016e697..e76126fbb0 100644 --- a/tests/phpunit/includes/api/ApiWatchTest.php +++ b/tests/phpunit/includes/api/ApiWatchTest.php @@ -64,7 +64,7 @@ class ApiWatchTest extends ApiTestCase { unset( $data[0]['query']['watchlist'][$index] ); } } - $this->assertSame( 0, count( $data[0]['query']['watchlist'] ) ); + $this->assertSame( [], $data[0]['query']['watchlist'] ); return $data; } diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 0c084e058a..5586fa1bec 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -610,7 +610,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $asycList[0](); // run the refresh callback $asycList = []; $this->assertEquals( 2, $wasSet, "Value calculated at later time" ); - $this->assertSame( 0, count( $asycList ), "No deferred refreshes added." ); + $this->assertSame( [], $asycList, "No deferred refreshes added." ); $v = $cache->getWithSetCallback( $key, 300, $func, $opts ); $this->assertEquals( $value, $v, "New value stored" ); diff --git a/tests/phpunit/includes/session/SessionBackendTest.php b/tests/phpunit/includes/session/SessionBackendTest.php index a1fdf8a3a6..eba1bcb35d 100644 --- a/tests/phpunit/includes/session/SessionBackendTest.php +++ b/tests/phpunit/includes/session/SessionBackendTest.php @@ -224,7 +224,7 @@ class SessionBackendTest extends MediaWikiTestCase { } $session2 = null; - $this->assertSame( 0, count( $priv->requests ) ); + $this->assertSame( [], $priv->requests ); $this->assertArrayNotHasKey( $backend->getId(), $manager->allSessionBackends ); $this->assertArrayHasKey( $backend->getId(), $manager->allSessionIds ); }