From e10d84b65dc608dcab49a568bc6a9160e4a0b999 Mon Sep 17 00:00:00 2001 From: Abel Date: Mon, 21 Jan 2019 20:34:45 +0100 Subject: [PATCH] Implemented @covers in all unit tests. Code coverage now shows better what is actually covered and what is not. --- src/FuzeWorks/ConfigORM/ConfigORMAbstract.php | 24 ++++ src/FuzeWorks/Configurator.php | 3 +- src/FuzeWorks/Factory.php | 6 +- src/FuzeWorks/Logger.php | 2 +- src/FuzeWorks/Plugins.php | 1 + test/core/core_configORMAbstractTest.php | 11 +- test/core/core_configTest.php | 28 ++-- test/core/core_configuratorTest.php | 53 ++++++- test/core/core_coreTest.php | 4 + test/core/core_eventTest.php | 14 ++ test/core/core_eventsTest.php | 38 ++++- test/core/core_factoryTest.php | 46 ++++++ test/core/core_helperTest.php | 16 ++- test/core/core_libraryTest.php | 33 +++++ test/core/core_loggerTest.php | 26 ++++ test/core/core_pluginsTest.php | 21 ++- test/core/core_priorityTest.php | 16 +++ test/events/event_coreStartEventTest.php | 2 +- test/mocks/autoloader.php | 136 ------------------ 19 files changed, 307 insertions(+), 173 deletions(-) delete mode 100644 test/mocks/autoloader.php diff --git a/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php b/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php index 5c75c01..c4c7070 100644 --- a/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php +++ b/src/FuzeWorks/ConfigORM/ConfigORMAbstract.php @@ -115,6 +115,18 @@ abstract class ConfigORMAbstract implements Iterator return $this->cfg[$name]; } + /** + * Return a value from a config file. + * + * @param string $name Key of the requested entry + * @return mixed Value of the requested entry + * @codeCoverageIgnore + */ + public function get($name) + { + return $this->cfg[$name]; + } + /** * Sets an entry in the config file. * @@ -127,6 +139,18 @@ abstract class ConfigORMAbstract implements Iterator $this->cfg[$name] = $value; } + /** + * Sets an entry in the config file. + * + * @param string $name Key of the entry + * @param mixed $value Value of the entry + * @codeCoverageIgnore + */ + public function set($name, $value) + { + $this->cfg[$name] = $value; + } + /** * Unset a value in a config file. * diff --git a/src/FuzeWorks/Configurator.php b/src/FuzeWorks/Configurator.php index 759a5d8..42a74e0 100644 --- a/src/FuzeWorks/Configurator.php +++ b/src/FuzeWorks/Configurator.php @@ -37,7 +37,6 @@ namespace FuzeWorks; use FuzeWorks\Exception\ConfiguratorException; use FuzeWorks\Exception\InvalidArgumentException; -use Tracy\Debugger; /** * Class Configurator. @@ -383,7 +382,7 @@ class Configurator } } - $container->init(); + $container->initFactory(); return $container; } } \ No newline at end of file diff --git a/src/FuzeWorks/Factory.php b/src/FuzeWorks/Factory.php index 5930f57..c0d69b4 100644 --- a/src/FuzeWorks/Factory.php +++ b/src/FuzeWorks/Factory.php @@ -76,7 +76,7 @@ class Factory * * @var bool Clone all Factory instances. */ - protected static $cloneInstances = false; + private static $cloneInstances = false; /** * Whether the Factory has been initialized or not @@ -158,7 +158,7 @@ class Factory * @return Factory * @throws CoreException */ - public function init(): Factory + public function initFactory(): Factory { // If already initialized, cancel if ($this->initialized) @@ -172,7 +172,7 @@ class Factory } // Disable events if requested to do so - if (!$cfg->enable_events) + if (!$cfg->get('enable_events')) { Events::disable(); } diff --git a/src/FuzeWorks/Logger.php b/src/FuzeWorks/Logger.php index 26322f7..c5fa2f7 100644 --- a/src/FuzeWorks/Logger.php +++ b/src/FuzeWorks/Logger.php @@ -112,7 +112,7 @@ class Logger { // Register the error handler, Untestable // @codeCoverageIgnoreStart - if ($cfg_error->fuzeworks_error_reporting == true) + if ($cfg_error->get('fuzeworks_error_reporting') == true) { self::enableHandlers(); } diff --git a/src/FuzeWorks/Plugins.php b/src/FuzeWorks/Plugins.php index cd91d65..2bf5029 100644 --- a/src/FuzeWorks/Plugins.php +++ b/src/FuzeWorks/Plugins.php @@ -91,6 +91,7 @@ class Plugins * Called upon creation of the plugins class. * * @return void + * @codeCoverageIgnore */ public function __construct() { diff --git a/test/core/core_configORMAbstractTest.php b/test/core/core_configORMAbstractTest.php index c998162..ab70046 100644 --- a/test/core/core_configORMAbstractTest.php +++ b/test/core/core_configORMAbstractTest.php @@ -40,11 +40,12 @@ use FuzeWorks\ConfigORM\ConfigORMAbstract; * Class ConfigORMAbstractTest * * Config testing suite, will test the special methods from ConfigORMAbstract + * @coversDefaultClass \FuzeWorks\ConfigORM\ConfigORMAbstract */ class ConfigORMAbstractTest extends CoreTestAbstract { /** - * @covers \FuzeWorks\ConfigORM\ConfigORMAbstract::revert + * @covers ::revert */ public function testRevert() { @@ -69,7 +70,7 @@ class ConfigORMAbstractTest extends CoreTestAbstract } /** - * @covers \FuzeWorks\ConfigORM\ConfigORMAbstract::replace + * @covers ::replace */ public function testReplaceWithNewValues() { @@ -97,7 +98,7 @@ class ConfigORMAbstractTest extends CoreTestAbstract /** * @depends testReplaceWithNewValues - * @covers \FuzeWorks\ConfigORM\ConfigORMAbstract::replace + * @covers ::replace */ public function testReplaceExistingValues() { @@ -125,7 +126,7 @@ class ConfigORMAbstractTest extends CoreTestAbstract } /** - * @covers \FuzeWorks\ConfigORM\ConfigORMAbstract::toArray + * @covers ::toArray */ public function testToArray() { @@ -144,7 +145,7 @@ class ConfigORMAbstractTest extends CoreTestAbstract /** * @depends testToArray - * @covers \FuzeWorks\ConfigORM\ConfigORMAbstract::clear + * @covers ::clear */ public function testClear() { diff --git a/test/core/core_configTest.php b/test/core/core_configTest.php index d636515..af52120 100644 --- a/test/core/core_configTest.php +++ b/test/core/core_configTest.php @@ -43,6 +43,7 @@ use FuzeWorks\Events; * Class ConfigTest. * * Config testing suite, will test basic config functionality while also testing default ORM's + * @coversDefaultClass \FuzeWorks\Config */ class configTest extends CoreTestAbstract { @@ -57,6 +58,9 @@ class configTest extends CoreTestAbstract $this->config = new Config(); } + /** + * @coversNothing + */ public function testGetConfigClass() { $this->assertInstanceOf('FuzeWorks\Config', $this->config); @@ -64,8 +68,8 @@ class configTest extends CoreTestAbstract /** * @depends testGetConfigClass - * @covers \FuzeWorks\Config::getConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::getConfig + * @covers ::loadConfigFile */ public function testLoadConfig() { @@ -74,8 +78,8 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig - * @covers \FuzeWorks\Config::getConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::getConfig + * @covers ::loadConfigFile */ public function testLoadConfigWithAltDirectory() { @@ -85,7 +89,7 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::loadConfigFile * @expectedException FuzeWorks\Exception\ConfigException */ public function testFileNotFound() @@ -95,7 +99,7 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::loadConfigFile */ public function testLoadConfigCancel() { @@ -112,7 +116,7 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::loadConfigFile */ public function testLoadConfigIntercept() { @@ -129,8 +133,8 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig - * @covers \FuzeWorks\Config::overrideConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::overrideConfig + * @covers ::loadConfigFile */ public function testLoadConfigOverride() { @@ -148,8 +152,8 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfigOverride - * @covers \FuzeWorks\Config::overrideConfig - * @covers \FuzeWorks\Config::loadConfigFile + * @covers ::overrideConfig + * @covers ::loadConfigFile */ public function testLoadConfigCoreOverride() { @@ -168,7 +172,7 @@ class configTest extends CoreTestAbstract } /** - * @covers \FuzeWorks\Config::getConfig + * @covers ::getConfig */ public function testSameConfigObject() { diff --git a/test/core/core_configuratorTest.php b/test/core/core_configuratorTest.php index 731e8d4..7b7c4a0 100644 --- a/test/core/core_configuratorTest.php +++ b/test/core/core_configuratorTest.php @@ -44,6 +44,7 @@ use FuzeWorks\Logger; * Class ConfiguratorTest. * * This test will test the Configurator class + * @coversDefaultClass \FuzeWorks\Configurator */ class configuratorTest extends CoreTestAbstract { @@ -67,11 +68,17 @@ class configuratorTest extends CoreTestAbstract Core::$logDir = dirname(__DIR__) . '/temp'; } + /** + * @coversNothing + */ public function testGetConfiguratorClass() { $this->assertInstanceOf('FuzeWorks\Configurator', $this->configurator); } + /** + * @coversNothing + */ public function testCreateContainer() { $this->assertInstanceOf('FuzeWorks\Factory', $this->configurator->createContainer()); @@ -81,6 +88,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::addComponent + * @covers ::createContainer */ public function testAddComponent() { @@ -98,6 +107,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testAddComponent + * @covers ::addComponent + * @covers ::createContainer */ public function testAddComponentClassByObject() { @@ -117,6 +128,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testAddComponent + * @covers ::addComponent + * @covers ::createContainer * @expectedException FuzeWorks\Exception\ConfiguratorException */ public function testAddComponentFail() @@ -126,7 +139,7 @@ class configuratorTest extends CoreTestAbstract $component = new FuzeWorks\Component\TestAddComponentFailComponent; $this->configurator->addComponent($component); - // Create container + // Create container and fail $this->configurator->createContainer(); } @@ -134,6 +147,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::setLogDirectory + * @covers ::createContainer */ public function testSetLogDirectory() { @@ -157,6 +172,7 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetLogDirectory + * @covers ::setLogDirectory * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetLogDirectoryNotDirectory() @@ -167,6 +183,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::setTempDirectory + * @covers ::createContainer */ public function testSetTempDirectory() { @@ -183,6 +201,7 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTempDirectory + * @covers ::setTempDirectory * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetTempDirectoryNotDirectory() @@ -194,6 +213,9 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer * @depends testAddComponent + * @covers ::addComponent + * @covers ::addDirectory + * @covers ::createContainer */ public function testAddComponentDirectory() { @@ -222,6 +244,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testAddComponent + * @covers ::deferComponentClassMethod + * @covers ::createContainer + * @covers \FuzeWorks\DeferredComponentClass::invoke + * @covers \FuzeWorks\DeferredComponentClass::isInvoked + * @covers \FuzeWorks\DeferredComponentClass::getResult */ public function testDeferComponentClassMethod() { @@ -251,6 +278,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testDeferComponentClassMethod + * @covers ::deferComponentClassMethod + * @covers ::createContainer + * @covers \FuzeWorks\DeferredComponentClass::invoke + * @covers \FuzeWorks\DeferredComponentClass::isInvoked + * @covers \FuzeWorks\DeferredComponentClass::getResult */ public function testDeferComponentClassMethodWithCallback() { @@ -285,6 +317,7 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::setTimeZone */ public function testSetTimezone() { @@ -298,6 +331,7 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTimezone * @expectedException \FuzeWorks\Exception\InvalidArgumentException + * @covers ::setTimeZone */ public function testSetTimezoneInvalid() { @@ -306,6 +340,8 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::setParameters + * @covers ::createContainer */ public function testSetParameter() { @@ -317,6 +353,11 @@ class configuratorTest extends CoreTestAbstract $this->assertEquals('fake_directory', Core::$tempDir); } + /** + * @depends testCreateContainer + * @covers ::setConfigOverride + * @covers ::createContainer + */ public function testSetConfigOverride() { // Set an override that can be verified @@ -333,6 +374,9 @@ class configuratorTest extends CoreTestAbstract /** * @depends testCreateContainer + * @covers ::enableDebugMode + * @covers ::isDebugMode + * @covers ::createContainer */ public function testEnableDebugMode() { @@ -355,6 +399,9 @@ class configuratorTest extends CoreTestAbstract /** * @depends testEnableDebugMode + * @covers ::enableDebugMode + * @covers ::isDebugMode + * @covers ::createContainer */ public function testDisableDebugMode() { @@ -369,6 +416,9 @@ class configuratorTest extends CoreTestAbstract /** * @depends testEnableDebugMode + * @covers ::setDebugAddress + * @covers ::enableDebugMode + * @covers ::isDebugMode */ public function testSetDebugAddress() { @@ -422,6 +472,7 @@ class configuratorTest extends CoreTestAbstract /** * @depends testEnableDebugMode + * @covers ::setDebugAddress * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetDebugAddressInvalidArgument() diff --git a/test/core/core_coreTest.php b/test/core/core_coreTest.php index 1fc4941..1749468 100644 --- a/test/core/core_coreTest.php +++ b/test/core/core_coreTest.php @@ -40,6 +40,7 @@ use FuzeWorks\Core; * Class CoreTest. * * Core testing suite, will test basic core functionality + * @coversDefaultClass \FuzeWorks\Core */ class coreTest extends CoreTestAbstract { @@ -63,6 +64,9 @@ class coreTest extends CoreTestAbstract $this->assertTrue(class_exists('FuzeWorks\Priority')); } + /** + * @covers ::isPHP + */ public function testIsPHP() { $this->assertTrue(Core::isPHP('1.2.0')); diff --git a/test/core/core_eventTest.php b/test/core/core_eventTest.php index fad77cf..5cd839d 100644 --- a/test/core/core_eventTest.php +++ b/test/core/core_eventTest.php @@ -41,10 +41,14 @@ use FuzeWorks\Priority; * Class EventTest. * * This test will test the Event class + * @coversDefaultClass \FuzeWorks\Event */ class eventTest extends CoreTestAbstract { + /** + * @coversNothing + */ public function testFireEvent() { $event = Events::fireEvent('testEvent'); @@ -52,6 +56,11 @@ class eventTest extends CoreTestAbstract $this->assertInstanceOf('FuzeWorks\Event', $event); } + /** + * @depends testFireEvent + * @covers ::isCancelled + * @covers ::setCancelled + */ public function testCancelEvent() { Events::addListener(array($this, 'listener_cancel'), 'testCancelEvent', Priority::NORMAL); @@ -60,6 +69,11 @@ class eventTest extends CoreTestAbstract $this->assertTrue($event->isCancelled()); } + /** + * @depends testCancelEvent + * @covers ::setCancelled + * @covers ::isCancelled + */ public function testUncancelEvent() { Events::addListener(array($this, 'listener_cancel'), 'testUncancelEvent', Priority::HIGH); diff --git a/test/core/core_eventsTest.php b/test/core/core_eventsTest.php index ef5ff7b..c9d1903 100644 --- a/test/core/core_eventsTest.php +++ b/test/core/core_eventsTest.php @@ -42,20 +42,26 @@ use FuzeWorks\Priority; * Class EventTest. * * This test will test Events + * @coversDefaultClass \FuzeWorks\Events */ class eventsTest extends CoreTestAbstract { + + /** + * @covers ::fireEvent + */ public function testFireEvent() { - $mock = $this->getMockBuilder(Observer::class)->setMethods(['mockMethod'])->getMock(); - $mock->expects($this->once())->method('mockMethod'); + $mock = $this->getMockBuilder(Observer::class)->setMethods(['mockListener'])->getMock(); + $mock->expects($this->once())->method('mockListener')->with($this->isInstanceOf('MockEvent')); - Events::addListener(array($mock, 'mockMethod'), 'mockEvent', Priority::NORMAL); + Events::addListener(array($mock, 'mockListener'), 'mockEvent', Priority::NORMAL); Events::fireEvent('mockEvent'); } /** * @depends testFireEvent + * @covers ::fireEvent */ public function testObjectEvent() { @@ -70,6 +76,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testObjectEvent + * @covers ::fireEvent */ public function testVariablePassing() { @@ -86,6 +93,10 @@ class eventsTest extends CoreTestAbstract Events::fireEvent($event); } + /** + * @depends testFireEvent + * @covers ::fireEvent + */ public function testEventArguments() { // Prepare test argument @@ -101,6 +112,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testVariablePassing + * @covers ::fireEvent */ public function testVariableChanging() { @@ -134,6 +146,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testFireEvent * @expectedException FuzeWorks\Exception\EventException + * @covers ::fireEvent */ public function testInvalidTypeEvent() { @@ -142,6 +155,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testFireEvent + * @covers ::fireEvent * @expectedException FuzeWorks\Exception\EventException */ public function testInvalidClassEvent() @@ -151,6 +165,8 @@ class eventsTest extends CoreTestAbstract /** * @depends testFireEvent + * @covers ::addListener + * @covers ::removeListener */ public function testAddAndRemoveListener() { @@ -168,6 +184,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::addListener * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidPriorityListener() @@ -177,6 +194,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::addListener * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidNameListener() @@ -186,6 +204,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::removeListener * @expectedException FuzeWorks\Exception\EventException */ public function testRemoveInvalidPriorityListener() @@ -195,6 +214,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::removeListener */ public function testRemoveUnsetEventListener() { @@ -203,6 +223,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::removeListener */ public function testRemoveUnsetListener() { @@ -212,6 +233,7 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener + * @covers ::addListener */ public function testListenerVariablePass() { @@ -228,6 +250,11 @@ class eventsTest extends CoreTestAbstract Events::fireEvent($event); } + /** + * @depends testFireEvent + * @covers ::disable + * @covers ::fireEvent + */ public function testDisable() { // First add the listener, expect it to be never called @@ -242,6 +269,11 @@ class eventsTest extends CoreTestAbstract Events::fireEvent('mockEvent'); } + /** + * @depends testDisable + * @covers ::disable + * @covers ::enable + */ public function testReEnable() { // First add the listener, expect it to be never called diff --git a/test/core/core_factoryTest.php b/test/core/core_factoryTest.php index 1dbd680..682ed74 100644 --- a/test/core/core_factoryTest.php +++ b/test/core/core_factoryTest.php @@ -41,9 +41,14 @@ use FuzeWorks\Exception\FactoryException; * Class FactoryTest. * * Will test the FuzeWorks Factory. + * @coversDefaultClass \FuzeWorks\Factory */ class factoryTest extends CoreTestAbstract { + + /** + * @covers ::getInstance + */ public function testCanLoadFactory() { $this->assertInstanceOf('FuzeWorks\Factory', Factory::getInstance()); @@ -51,6 +56,7 @@ class factoryTest extends CoreTestAbstract /** * @depends testCanLoadFactory + * @covers ::getInstance */ public function testLoadSameInstance() { @@ -59,6 +65,8 @@ class factoryTest extends CoreTestAbstract /** * @depends testCanLoadFactory + * @covers ::getInstance + * @covers ::cloneInstance */ public function testLoadDifferentInstance() { @@ -71,6 +79,8 @@ class factoryTest extends CoreTestAbstract /** * @depends testCanLoadFactory + * @covers ::getInstance + * @covers ::setInstance */ public function testObjectsSameInstance() { @@ -97,6 +107,9 @@ class factoryTest extends CoreTestAbstract /** * @depends testObjectsSameInstance + * @covers ::getInstance + * @covers ::setInstance + * @covers ::cloneInstance */ public function testObjectsDifferentInstance() { @@ -117,6 +130,9 @@ class factoryTest extends CoreTestAbstract $factory3 = Factory::getInstance(true)->setInstance('Mock', $mock); $factory4 = Factory::getInstance(true)->setInstance('Mock', $mock); + // Should be same for now + $this->assertSame($factory3->mock, $factory4->mock); + // Clone the instance in factory4 $factory4->cloneInstance('Mock'); @@ -125,6 +141,8 @@ class factoryTest extends CoreTestAbstract } /** + * @depends testCanLoadFactory + * @covers ::cloneInstance * @expectedException FuzeWorks\Exception\FactoryException */ public function testCloneInstanceWrongClassname() @@ -136,6 +154,13 @@ class factoryTest extends CoreTestAbstract $factory->cloneInstance('fake'); } + /** + * @depends testCanLoadFactory + * @covers ::enableCloneInstances + * @covers ::disableCloneInstances + * @covers ::cloneInstance + * @covers ::getInstance + */ public function testGlobalCloneInstance() { // First test without global cloning @@ -154,6 +179,11 @@ class factoryTest extends CoreTestAbstract $this->assertSame(Factory::getInstance(), Factory::getInstance()); } + /** + * @depends testCanLoadFactory + * @covers ::getInstance + * @covers ::newInstance + */ public function testNewFactoryInstance() { // Load the different factories @@ -176,6 +206,8 @@ class factoryTest extends CoreTestAbstract } /** + * @depends testNewFactoryInstance + * @covers ::newInstance * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceNotExist() @@ -188,6 +220,8 @@ class factoryTest extends CoreTestAbstract } /** + * @depends testNewFactoryInstance + * @covers ::newInstance * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceWrongNamespace() @@ -199,6 +233,11 @@ class factoryTest extends CoreTestAbstract $factory->newInstance('helpers', 'Test\\'); } + /** + * @depends testNewFactoryInstance + * @covers ::setInstance + * @covers ::removeInstance + */ public function testRemoveInstance() { // Load the factory @@ -222,6 +261,8 @@ class factoryTest extends CoreTestAbstract } /** + * @depends testRemoveInstance + * @covers ::removeInstance * @expectedException FuzeWorks\Exception\FactoryException */ public function testRemoveInstanceNotExist() @@ -233,6 +274,11 @@ class factoryTest extends CoreTestAbstract $factory->removeInstance('fake'); } + /** + * @depends testCanLoadFactory + * @covers ::instanceIsset + * @covers ::setInstance + */ public function testInstanceIsset() { // Load the factory diff --git a/test/core/core_helperTest.php b/test/core/core_helperTest.php index 8e0543f..a86a64c 100644 --- a/test/core/core_helperTest.php +++ b/test/core/core_helperTest.php @@ -42,6 +42,7 @@ use FuzeWorks\Helpers; * Class HelperTest. * * Helpers testing suite, will test basic loading of Helpers + * @coversDefaultClass \FuzeWorks\Helpers */ class helperTest extends CoreTestAbstract { @@ -58,13 +59,16 @@ class helperTest extends CoreTestAbstract $this->helpers->setDirectories([3 => ['test' . DS . 'helpers']]); } + /** + * @coversNothing + */ public function testGetHelpersClass() { $this->assertInstanceOf('FuzeWorks\Helpers', $this->helpers); } /** - * @covers \FuzeWorks\Helpers::load + * @covers ::load */ public function testLoadHelper() { @@ -80,7 +84,7 @@ class helperTest extends CoreTestAbstract /** * @depends testLoadHelper - * @covers \FuzeWorks\Helpers::load + * @covers ::load */ public function testLoadHelperWithoutSubdirectory() { @@ -96,7 +100,7 @@ class helperTest extends CoreTestAbstract /** * @depends testLoadHelper - * @covers \FuzeWorks\Helpers::load + * @covers ::load */ public function testLoadHelperWithAltDirectory() { @@ -112,7 +116,7 @@ class helperTest extends CoreTestAbstract /** * @depends testLoadHelper - * @covers \FuzeWorks\Helpers::load + * @covers ::load */ public function testReloadHelper() { @@ -134,7 +138,7 @@ class helperTest extends CoreTestAbstract /** * @depends testLoadHelper - * @covers \FuzeWorks\Helpers::load + * @covers ::load */ public function testCancelLoadHelper() { @@ -152,7 +156,7 @@ class helperTest extends CoreTestAbstract /** * @depends testLoadHelper - * @covers \FuzeWorks\Helpers::get + * @covers ::get */ public function testGetHelper() { diff --git a/test/core/core_libraryTest.php b/test/core/core_libraryTest.php index 0849480..256ed35 100644 --- a/test/core/core_libraryTest.php +++ b/test/core/core_libraryTest.php @@ -42,6 +42,7 @@ use FuzeWorks\Libraries; * Class LibraryTest. * * Libraries testing suite, will test basic loading of and management of Libraries + * @coversDefaultClass \FuzeWorks\Libraries */ class libraryTest extends CoreTestAbstract { @@ -60,6 +61,9 @@ class libraryTest extends CoreTestAbstract $this->libraries->setDirectories([3 => ['test'.DS.'libraries']]); } + /** + * @coversNothing + */ public function testLibrariesClass() { $this->assertInstanceOf('FuzeWorks\Libraries', $this->libraries); @@ -69,6 +73,8 @@ class libraryTest extends CoreTestAbstract /** * @depends testLibrariesClass + * @covers ::get + * @covers ::initLibrary */ public function testGetLibraryFromDirectory() { @@ -77,6 +83,8 @@ class libraryTest extends CoreTestAbstract /** * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary */ public function testGetLibraryFromSubdirectory() { @@ -88,6 +96,8 @@ class libraryTest extends CoreTestAbstract /** * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary */ public function testGetLibraryFromAltDirectory() { @@ -97,6 +107,9 @@ class libraryTest extends CoreTestAbstract } /** + * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryFail() @@ -105,6 +118,9 @@ class libraryTest extends CoreTestAbstract } /** + * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoName() @@ -113,6 +129,9 @@ class libraryTest extends CoreTestAbstract } /** + * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoClass() @@ -120,6 +139,11 @@ class libraryTest extends CoreTestAbstract $this->libraries->get('TestGetLibraryNoClass'); } + /** + * @depends testGetLibraryFromDirectory + * @covers ::get + * @covers ::initLibrary + */ public function testGetLibraryParametersFromConfig() { // Prepare the config file @@ -137,6 +161,10 @@ class libraryTest extends CoreTestAbstract /* ---------------------------------- Add libraries --------------------------------------------- */ + /** + * @covers ::addLibraryObject + * @covers ::get + */ public function testAddLibraryObject() { $this->libraries->addLibraryObject('TestAddLibraryObject', 5); @@ -144,6 +172,10 @@ class libraryTest extends CoreTestAbstract $this->assertEquals(5, $this->libraries->get('TestAddLibraryObject')); } + /** + * @covers ::addLibraryClass + * @covers ::get + */ public function testAddLibraryClass() { require_once('test'.DS.'libraries'.DS.'TestAddLibraryClass'.DS.'TestAddLibraryClass.php'); @@ -155,6 +187,7 @@ class libraryTest extends CoreTestAbstract /** * @depends testAddLibraryClass + * @covers ::addLibraryClass * @expectedException \FuzeWorks\Exception\LibraryException */ public function testAddLibraryClassFail() diff --git a/test/core/core_loggerTest.php b/test/core/core_loggerTest.php index 95851d9..0a9bb51 100644 --- a/test/core/core_loggerTest.php +++ b/test/core/core_loggerTest.php @@ -43,6 +43,7 @@ use FuzeWorks\Exception\LoggerException; * Class ModelTest. * * Will test the FuzeWorks Model System. + * @coversDefaultClass \FuzeWorks\Logger */ class loggerTest extends CoreTestAbstract { @@ -56,6 +57,9 @@ class loggerTest extends CoreTestAbstract Logger::$logs = array(); } + /** + * @coversNothing + */ public function testGetLogger() { $this->assertInstanceOf('FuzeWorks\Logger', new Logger); @@ -63,6 +67,9 @@ class loggerTest extends CoreTestAbstract $this->assertInstanceOf('FuzeWorks\Logger', new Logger); } + /** + * @covers ::errorHandler + */ public function testErrorHandler() { Logger::errorHandler(E_ERROR, 'Example error', __FILE__, 1); @@ -77,6 +84,8 @@ class loggerTest extends CoreTestAbstract /** * @depends testErrorHandler + * @covers ::errorHandler + * @covers ::getType */ public function testErrorHandlerTypes() { @@ -114,6 +123,9 @@ class loggerTest extends CoreTestAbstract } } + /** + * @covers ::exceptionHandler + */ public function testExceptionHandler() { // Create the exception @@ -129,6 +141,9 @@ class loggerTest extends CoreTestAbstract Logger::exceptionHandler($exception); } + /** + * @covers ::log + */ public function testLog() { // Log the message @@ -147,6 +162,12 @@ class loggerTest extends CoreTestAbstract /** * @depends testLog + * @covers ::newLevel + * @covers ::stopLevel + * @covers ::logError + * @covers ::logWarning + * @covers ::logDebug + * @covers ::mark */ public function testLogTypes() { @@ -174,6 +195,11 @@ class loggerTest extends CoreTestAbstract } } + /** + * @covers ::enable + * @covers ::disable + * @covers ::isEnabled + */ public function testEnableDisable() { // First enable diff --git a/test/core/core_pluginsTest.php b/test/core/core_pluginsTest.php index b1a9986..48a63d1 100644 --- a/test/core/core_pluginsTest.php +++ b/test/core/core_pluginsTest.php @@ -42,6 +42,7 @@ use FuzeWorks\Plugins; * Class PluginsTest. * * Plugins testing suite, will test basic loading of and management of Plugins + * @coversDefaultClass \FuzeWorks\Plugins */ class pluginTest extends CoreTestAbstract { @@ -58,6 +59,9 @@ class pluginTest extends CoreTestAbstract $this->plugins->loadHeadersFromPluginPaths(); } + /** + * @coversNothing + */ public function testGetPluginsClass() { $this->assertInstanceOf('FuzeWorks\Plugins', $this->plugins); @@ -65,6 +69,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testGetPluginsClass + * @covers ::get */ public function testLoadPlugin() { @@ -73,6 +78,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get */ public function testReloadPlugin() { @@ -81,6 +87,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get */ public function testLoadHeader() { @@ -97,6 +104,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingHeader() @@ -106,6 +114,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get */ public function testGetPluginMethod() { @@ -114,6 +123,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get */ public function testGetPluginWithClassFile() { @@ -122,6 +132,7 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingPlugin() @@ -131,18 +142,17 @@ class pluginTest extends CoreTestAbstract /** * @depends testMissingPlugin + * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testLoadHeaderNotIPluginHeader() { - // Attempt to load all headers - $this->plugins->loadHeadersFromPluginPaths(); - $this->plugins->get('TestLoadHeaderNotIPluginHeader'); } /** * @depends testLoadPlugin + * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testInvalidClass() @@ -151,6 +161,7 @@ class pluginTest extends CoreTestAbstract } /** + * @covers ::get * @expectedException FuzeWorks\Exception\PluginException */ public function testGetMissingName() @@ -160,6 +171,8 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get + * @covers ::loadHeadersFromPluginPaths * @expectedException FuzeWorks\Exception\PluginException */ public function testDisabledPlugin() @@ -171,6 +184,8 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin + * @covers ::get + * @covers ::loadHeadersFromPluginPaths * @expectedException FuzeWorks\Exception\PluginException */ public function testRunInvalidDirectory() diff --git a/test/core/core_priorityTest.php b/test/core/core_priorityTest.php index 4b198d1..57ef1ab 100644 --- a/test/core/core_priorityTest.php +++ b/test/core/core_priorityTest.php @@ -39,10 +39,14 @@ use FuzeWorks\Priority; * Class priorityTest. * * This test will test the Priority class + * @coversDefaultClass \FuzeWorks\Priority */ class priorityTest extends CoreTestAbstract { + /** + * @coversNothing + */ public function testPriorities() { $this->assertEquals(Priority::LOWEST, 5); @@ -53,6 +57,9 @@ class priorityTest extends CoreTestAbstract $this->assertEquals(Priority::MONITOR, 0); } + /** + * @covers ::getPriority + */ public function testGetPriority() { $this->assertEquals(Priority::getPriority(5), 'Priority::LOWEST'); @@ -63,16 +70,25 @@ class priorityTest extends CoreTestAbstract $this->assertEquals(Priority::getPriority(0), 'Priority::MONITOR'); } + /** + * @covers ::getPriority + */ public function testGetInvalidPriority() { $this->assertFalse(Priority::getPriority(99)); } + /** + * @covers ::getHighestPriority + */ public function testHighestPriority() { $this->assertEquals(Priority::getHighestPriority(), Priority::MONITOR); } + /** + * @covers ::getLowestPriority + */ public function testLowestPriority() { $this->assertEquals(Priority::getLowestPriority(), Priority::LOWEST); diff --git a/test/events/event_coreStartEventTest.php b/test/events/event_coreStartEventTest.php index f5a3354..a8677e2 100644 --- a/test/events/event_coreStartEventTest.php +++ b/test/events/event_coreStartEventTest.php @@ -52,7 +52,7 @@ class coreStartEventTest extends CoreTestAbstract Events::addListener(array($mock, 'mockMethod'), 'coreStartEvent', Priority::NORMAL); $factory = new Factory; - $factory->init(); + $factory->initFactory(); } } diff --git a/test/mocks/autoloader.php b/test/mocks/autoloader.php deleted file mode 100644 index 8ffc3c5..0000000 --- a/test/mocks/autoloader.php +++ /dev/null @@ -1,136 +0,0 @@ -