tests: Replace assertions on count() == 0 with strict === []
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 30 Sep 2019 14:20:34 +0000 (16:20 +0200)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 30 Sep 2019 14:20:34 +0000 (16:20 +0200)
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

tests/phpunit/includes/api/ApiWatchTest.php
tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php
tests/phpunit/includes/session/SessionBackendTest.php

index 24d016e..e76126f 100644 (file)
@@ -64,7 +64,7 @@ class ApiWatchTest extends ApiTestCase {
                                unset( $data[0]['query']['watchlist'][$index] );
                        }
                }
                                unset( $data[0]['query']['watchlist'][$index] );
                        }
                }
-               $this->assertSame( 0, count( $data[0]['query']['watchlist'] ) );
+               $this->assertSame( [], $data[0]['query']['watchlist'] );
 
                return $data;
        }
 
                return $data;
        }
index 0c084e0..5586fa1 100644 (file)
@@ -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" );
                $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" );
 
                $v = $cache->getWithSetCallback( $key, 300, $func, $opts );
                $this->assertEquals( $value, $v, "New value stored" );
 
index a1fdf8a..eba1bcb 100644 (file)
@@ -224,7 +224,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                }
 
                $session2 = null;
                }
 
                $session2 = null;
-               $this->assertSame( 0, count( $priv->requests ) );
+               $this->assertSame( [], $priv->requests );
                $this->assertArrayNotHasKey( $backend->getId(), $manager->allSessionBackends );
                $this->assertArrayHasKey( $backend->getId(), $manager->allSessionIds );
        }
                $this->assertArrayNotHasKey( $backend->getId(), $manager->allSessionBackends );
                $this->assertArrayHasKey( $backend->getId(), $manager->allSessionIds );
        }