Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Use better assertion in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Apr 27, 2018
1 parent 8faaf2a commit 46ba18a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions test/AutoloaderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testRegisteringValidMapFilePopulatesAutoloader()
$loader = AutoloaderFactory::getRegisteredAutoloader('Zend\Loader\ClassMapAutoloader');
$map = $loader->getAutoloadMap();
$this->assertInternalType('array', $map);
$this->assertEquals(2, count($map));
$this->assertCount(2, $map);
}

/**
Expand All @@ -85,15 +85,15 @@ public function testFactoryDoesNotRegisterDuplicateAutoloaders()
],
],
]);
$this->assertEquals(1, count(AutoloaderFactory::getRegisteredAutoloaders()));
$this->assertCount(1, AutoloaderFactory::getRegisteredAutoloaders());
AutoloaderFactory::factory([
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
'ZendTest\Loader\TestAsset\TestPlugins' => __DIR__ . '/TestAsset/TestPlugins',
],
],
]);
$this->assertEquals(1, count(AutoloaderFactory::getRegisteredAutoloaders()));
$this->assertCount(1, AutoloaderFactory::getRegisteredAutoloaders());
$this->assertTrue(class_exists('TestNamespace\NoDuplicateAutoloadersCase'));
$this->assertTrue(class_exists('ZendTest\Loader\TestAsset\TestPlugins\Foo'));
}
Expand All @@ -108,7 +108,7 @@ public function testCanUnregisterAutoloaders()
],
]);
AutoloaderFactory::unregisterAutoloaders();
$this->assertEquals(0, count(AutoloaderFactory::getRegisteredAutoloaders()));
$this->assertCount(0, AutoloaderFactory::getRegisteredAutoloaders());
}

public function testCanUnregisterAutoloadersByClassName()
Expand All @@ -121,7 +121,7 @@ public function testCanUnregisterAutoloadersByClassName()
],
]);
AutoloaderFactory::unregisterAutoloader('Zend\Loader\StandardAutoloader');
$this->assertEquals(0, count(AutoloaderFactory::getRegisteredAutoloaders()));
$this->assertCount(0, AutoloaderFactory::getRegisteredAutoloaders());
}

public function testCanGetValidRegisteredAutoloader()
Expand All @@ -142,7 +142,7 @@ public function testDefaultAutoloader()
AutoloaderFactory::factory();
$autoloader = AutoloaderFactory::getRegisteredAutoloader('Zend\Loader\StandardAutoloader');
$this->assertInstanceOf('Zend\Loader\StandardAutoloader', $autoloader);
$this->assertEquals(1, count(AutoloaderFactory::getRegisteredAutoloaders()));
$this->assertCount(1, AutoloaderFactory::getRegisteredAutoloaders());
}

public function testGetInvalidAutoloaderThrowsException()
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testPassingNoArgumentsToFactoryInstantiatesAndRegistersStandardA
{
AutoloaderFactory::factory();
$loaders = AutoloaderFactory::getRegisteredAutoloaders();
$this->assertEquals(1, count($loaders));
$this->assertCount(1, $loaders);
$loader = array_shift($loaders);
$this->assertInstanceOf('Zend\Loader\StandardAutoloader', $loader);

Expand Down
10 changes: 5 additions & 5 deletions test/ClassMapAutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ public function testRegisteringValidMapFilePopulatesAutoloader()
$this->loader->registerAutoloadMap(__DIR__ . '/_files/goodmap.php');
$map = $this->loader->getAutoloadMap();
$this->assertInternalType('array', $map);
$this->assertEquals(2, count($map));
$this->assertCount(2, $map);
// Just to make sure nothing changes after loading the same map again
// (loadMapFromFile should just return)
$this->loader->registerAutoloadMap(__DIR__ . '/_files/goodmap.php');
$map = $this->loader->getAutoloadMap();
$this->assertInternalType('array', $map);
$this->assertEquals(2, count($map));
$this->assertCount(2, $map);
}

public function testRegisteringMultipleMapsMergesThem()
Expand All @@ -114,7 +114,7 @@ public function testRegisteringMultipleMapsMergesThem()

$test = $this->loader->getAutoloadMap();
$this->assertInternalType('array', $test);
$this->assertEquals(3, count($test));
$this->assertCount(3, $test);
$this->assertNotEquals(
$map['ZendTest\Loader\StandardAutoloaderTest'],
$test['ZendTest\Loader\StandardAutoloaderTest']
Expand All @@ -133,7 +133,7 @@ public function testCanRegisterMultipleMapsAtOnce()
$this->loader->registerAutoloadMaps($maps);
$test = $this->loader->getAutoloadMap();
$this->assertInternalType('array', $test);
$this->assertEquals(3, count($test));
$this->assertCount(3, $test);
}

public function testRegisterMapsThrowsExceptionForNonTraversableArguments()
Expand Down Expand Up @@ -191,6 +191,6 @@ public function testCanLoadClassMapFromPhar()
// @codingStandardsIgnoreEnd
$this->loader->registerAutoloadMap($map);
$test = $this->loader->getAutoloadMap();
$this->assertEquals(1, count($test));
$this->assertCount(1, $test);
}
}

0 comments on commit 46ba18a

Please sign in to comment.