From 3ebd91d2ef6b3b369e4f2f92ee7d46055e58242f Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Fri, 31 Jul 2020 14:29:37 +0200 Subject: [PATCH] Updated PHPUnit to ^9 and vfsStream to ~1.6.0. - This resulted in some changes needing to be made in the test folder. All tests have been updated to work with these updated dependencies. - Also, PHP 7.1 is no longer supported. - psr/log is no longer a dependency of Core --- composer.json | 7 ++--- test/autoload.php | 4 +-- test/bootstrap.php | 5 ++- test/core/abstract.coreTestAbstract.php | 5 ++- test/core/core_configTest.php | 7 +++-- test/core/core_configuratorTest.php | 19 +++++------ test/core/core_eventsTest.php | 13 ++++---- test/core/core_exceptionTest.php | 42 +++++++------------------ test/core/core_factoryTest.php | 14 ++++----- test/core/core_helperTest.php | 4 +-- test/core/core_libraryTest.php | 17 +++++----- test/core/core_loggerTest.php | 6 ++-- test/core/core_pluginsTest.php | 21 +++++++------ test/phpunit.xml | 7 ----- 14 files changed, 72 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index a505137..d2aa1b5 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,11 @@ } ], "require": { - "php": ">=7.1.0", - "psr/log": "~1.1.0" + "php": ">=7.2.0" }, "require-dev": { - "phpunit/phpunit": "^7", - "mikey179/vfsstream": "1.1.*" + "phpunit/phpunit": "^9", + "mikey179/vfsstream": "~1.6.0" }, "autoload": { "psr-4": { diff --git a/test/autoload.php b/test/autoload.php index 0002526..859a051 100644 --- a/test/autoload.php +++ b/test/autoload.php @@ -31,11 +31,9 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ -use FuzeWorks\Config; -use FuzeWorks\Core; use FuzeWorks\Logger; // First set the working directory diff --git a/test/bootstrap.php b/test/bootstrap.php index 0ef3c1c..d5f961d 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ require_once(dirname(__DIR__) . '/vendor/autoload.php'); @@ -45,9 +45,8 @@ $configurator->setLogDirectory(__DIR__ . '/temp'); $configurator->setTimeZone('Europe/Amsterdam'); // Debug related -$configurator->enableDebugMode(true); +$configurator->enableDebugMode(); $configurator->setDebugAddress('ALL'); -//$configurator->setDebugEmail('example@mail.com'); $container = $configurator->createContainer(); return $container; diff --git a/test/core/abstract.coreTestAbstract.php b/test/core/abstract.coreTestAbstract.php index af4db16..f9901cd 100644 --- a/test/core/abstract.coreTestAbstract.php +++ b/test/core/abstract.coreTestAbstract.php @@ -31,14 +31,13 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use PHPUnit\Framework\TestCase; use FuzeWorks\Events; use FuzeWorks\Factory; use FuzeWorks\Core; use FuzeWorks\Config; -use FuzeWorks\LoggerTracyBridge; /** * Class CoreTestAbstract. @@ -50,7 +49,7 @@ abstract class CoreTestAbstract extends TestCase /** * Reset multiple components to their original state before running the next test */ - public function tearDown() + public function tearDown(): void { // Clear all events created by tests Events::$listeners = []; diff --git a/test/core/core_configTest.php b/test/core/core_configTest.php index 83003cb..034414e 100644 --- a/test/core/core_configTest.php +++ b/test/core/core_configTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Config; use FuzeWorks\Event\ConfigGetEvent; +use FuzeWorks\Exception\ConfigException; use FuzeWorks\Priority; use FuzeWorks\Events; @@ -53,7 +54,7 @@ class configTest extends CoreTestAbstract */ protected $config; - public function setUp() + public function setUp(): void { $this->config = new Config(); } @@ -90,10 +91,10 @@ class configTest extends CoreTestAbstract /** * @depends testLoadConfig * @covers ::loadConfigFile - * @expectedException FuzeWorks\Exception\ConfigException */ public function testFileNotFound() { + $this->expectException(ConfigException::class); $this->config->getConfig('notFound'); } diff --git a/test/core/core_configuratorTest.php b/test/core/core_configuratorTest.php index 3ec6063..53a55c8 100644 --- a/test/core/core_configuratorTest.php +++ b/test/core/core_configuratorTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.2.0 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Configurator; use FuzeWorks\Core; +use FuzeWorks\Exception\ConfiguratorException; use FuzeWorks\Factory; use FuzeWorks\iComponent; use FuzeWorks\Logger; @@ -54,7 +55,7 @@ class configuratorTest extends CoreTestAbstract */ protected $configurator; - public function setUp() + public function setUp(): void { $this->configurator = new Configurator; $this->configurator->setTempDirectory(dirname(__DIR__) . '/temp'); @@ -62,7 +63,7 @@ class configuratorTest extends CoreTestAbstract $this->configurator->setTimeZone('Europe/Amsterdam'); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); @@ -132,7 +133,6 @@ class configuratorTest extends CoreTestAbstract * @depends testAddComponent * @covers ::addComponent * @covers ::createContainer - * @expectedException FuzeWorks\Exception\ConfiguratorException */ public function testAddComponentFail() { @@ -142,6 +142,7 @@ class configuratorTest extends CoreTestAbstract $this->configurator->addComponent($component); // Create container and fail + $this->expectException(ConfiguratorException::class); $this->configurator->createContainer(); } @@ -175,11 +176,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetLogDirectory * @covers ::setLogDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetLogDirectoryNotDirectory() { // Set the directory + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setLogDirectory('not_exist'); } @@ -204,11 +205,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTempDirectory * @covers ::setTempDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetTempDirectoryNotDirectory() { // Set the directory + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setTempDirectory('not_exist'); } @@ -245,10 +246,10 @@ class configuratorTest extends CoreTestAbstract /** * @depends testAddComponentDirectory * @covers ::addDirectory - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testAddComponentDirectoryNotExist() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->addDirectory('not_exist', 'irrelevant'); } @@ -342,11 +343,11 @@ class configuratorTest extends CoreTestAbstract /** * @depends testSetTimezone - * @expectedException \FuzeWorks\Exception\InvalidArgumentException * @covers ::setTimeZone */ public function testSetTimezoneInvalid() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setTimeZone('Europe/Amsterdamned'); } @@ -472,10 +473,10 @@ class configuratorTest extends CoreTestAbstract /** * @depends testEnableDebugMode * @covers ::setDebugAddress - * @expectedException \FuzeWorks\Exception\InvalidArgumentException */ public function testSetDebugAddressInvalidArgument() { + $this->expectException(\FuzeWorks\Exception\InvalidArgumentException::class); $this->configurator->setDebugAddress(null); } } diff --git a/test/core/core_eventsTest.php b/test/core/core_eventsTest.php index c9d1903..f29f2ed 100644 --- a/test/core/core_eventsTest.php +++ b/test/core/core_eventsTest.php @@ -31,11 +31,12 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Event; use FuzeWorks\Events; +use FuzeWorks\Exception\EventException; use FuzeWorks\Priority; /** @@ -145,21 +146,21 @@ class eventsTest extends CoreTestAbstract /** * @depends testFireEvent - * @expectedException FuzeWorks\Exception\EventException * @covers ::fireEvent */ public function testInvalidTypeEvent() { + $this->expectException(EventException::class); Events::fireEvent(array('x', 'y', 'z')); } /** * @depends testFireEvent * @covers ::fireEvent - * @expectedException FuzeWorks\Exception\EventException */ public function testInvalidClassEvent() { + $this->expectException(EventException::class); Events::fireEvent('nonExistingEvent', 'x', 'y', 'z'); } @@ -185,30 +186,30 @@ class eventsTest extends CoreTestAbstract /** * @depends testAddAndRemoveListener * @covers ::addListener - * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidPriorityListener() { + $this->expectException(EventException::class); Events::addListener(function($event){}, 'mockEvent', 99); } /** * @depends testAddAndRemoveListener * @covers ::addListener - * @expectedException FuzeWorks\Exception\EventException */ public function testAddInvalidNameListener() { + $this->expectException(EventException::class); Events::addListener(function($e) {}, '', Priority::NORMAL); } /** * @depends testAddAndRemoveListener * @covers ::removeListener - * @expectedException FuzeWorks\Exception\EventException */ public function testRemoveInvalidPriorityListener() { + $this->expectException(EventException::class); Events::removeListener(function($event){}, 'mockEvent', 99); } diff --git a/test/core/core_exceptionTest.php b/test/core/core_exceptionTest.php index f09786c..e99fc3d 100644 --- a/test/core/core_exceptionTest.php +++ b/test/core/core_exceptionTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Exception\Exception; @@ -53,83 +53,63 @@ use FuzeWorks\Exception\ConfiguratorException; class exceptionTestTest extends CoreTestAbstract { - /** - * @expectedException FuzeWorks\Exception\Exception - */ public function testException() { + $this->expectException(Exception::class); throw new Exception("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\CoreException - */ public function testCoreException() { + $this->expectException(CoreException::class); throw new CoreException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\ConfigException - */ public function testConfigException() { + $this->expectException(ConfigException::class); throw new ConfigException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\EventException - */ public function testEventException() { + $this->expectException(EventException::class); throw new EventException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\FactoryException - */ public function testFactoryException() { + $this->expectException(FactoryException::class); throw new FactoryException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\HelperException - */ public function testHelperException() { + $this->expectException(HelperException::class); throw new HelperException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\InvalidArgumentException - */ public function testInvalidArgumentException() { + $this->expectException(InvalidArgumentException::class); throw new InvalidArgumentException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\LibraryException - */ public function testLibraryException() { + $this->expectException(LibraryException::class); throw new LibraryException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\LoggerException - */ public function testLoggerException() { + $this->expectException(LoggerException::class); throw new LoggerException("Exception Test Run", 1); } - /** - * @expectedException FuzeWorks\Exception\ConfiguratorException - */ public function testConfiguratorException() { + $this->expectException(ConfiguratorException::class); throw new ConfiguratorException("Exception Test Run", 1); } diff --git a/test/core/core_factoryTest.php b/test/core/core_factoryTest.php index df25b51..2febdc1 100644 --- a/test/core/core_factoryTest.php +++ b/test/core/core_factoryTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Factory; @@ -73,10 +73,10 @@ class factoryTest extends CoreTestAbstract /** * @depends testGetInstance * @covers ::getInstance - * @expectedException \FuzeWorks\Exception\FactoryException */ public function testGetInstanceNotFound() { + $this->expectException(FactoryException::class); Factory::getInstance('NotFound'); } @@ -183,7 +183,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testCanLoadFactory * @covers ::cloneInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testCloneInstanceWrongClassname() { @@ -191,6 +190,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Attempt + $this->expectException(FactoryException::class); $factory->cloneInstance('fake'); } @@ -223,7 +223,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testNewFactoryInstance * @covers ::newInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceNotExist() { @@ -231,13 +230,13 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // First, it does not exist + $this->expectException(FactoryException::class); $factory->newInstance('fake'); } /** * @depends testNewFactoryInstance * @covers ::newInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testFactoryNewInstanceWrongNamespace() { @@ -245,6 +244,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Second, it just fails + $this->expectException(FactoryException::class); $factory->newInstance('helpers', 'Test\\'); } @@ -278,7 +278,6 @@ class factoryTest extends CoreTestAbstract /** * @depends testRemoveInstance * @covers ::removeInstance - * @expectedException FuzeWorks\Exception\FactoryException */ public function testRemoveInstanceNotExist() { @@ -286,6 +285,7 @@ class factoryTest extends CoreTestAbstract $factory = new Factory; // Test + $this->expectException(FactoryException::class); $factory->removeInstance('fake'); } @@ -308,7 +308,7 @@ class factoryTest extends CoreTestAbstract $this->assertEquals(5, $factory->test); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_helperTest.php b/test/core/core_helperTest.php index a86a64c..10c3a91 100644 --- a/test/core/core_helperTest.php +++ b/test/core/core_helperTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Priority; @@ -52,7 +52,7 @@ class helperTest extends CoreTestAbstract */ protected $helpers; - public function setUp() + public function setUp(): void { // Prepare class $this->helpers = new Helpers(); diff --git a/test/core/core_libraryTest.php b/test/core/core_libraryTest.php index 123513e..6eb12e1 100644 --- a/test/core/core_libraryTest.php +++ b/test/core/core_libraryTest.php @@ -31,10 +31,11 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Core; +use FuzeWorks\Exception\LibraryException; use FuzeWorks\Factory; use FuzeWorks\Libraries; @@ -52,7 +53,7 @@ class libraryTest extends CoreTestAbstract */ protected $libraries; - public function setUp() + public function setUp(): void { // Load new libraries class $this->libraries = new Libraries(); @@ -110,10 +111,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryFail() { + $this->expectException(LibraryException::class); $this->libraries->get('FailLoadLibrary'); } @@ -121,10 +122,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoName() { + $this->expectException(LibraryException::class); $this->libraries->get(''); } @@ -132,10 +133,10 @@ class libraryTest extends CoreTestAbstract * @depends testGetLibraryFromDirectory * @covers ::get * @covers ::initLibrary - * @expectedException FuzeWorks\Exception\LibraryException */ public function testGetLibraryNoClass() { + $this->expectException(LibraryException::class); $this->libraries->get('TestGetLibraryNoClass'); } @@ -188,10 +189,10 @@ class libraryTest extends CoreTestAbstract /** * @depends testAddLibraryClass * @covers ::addLibraryClass - * @expectedException \FuzeWorks\Exception\LibraryException */ public function testAddLibraryClassFail() { + $this->expectException(LibraryException::class); $this->libraries->addLibraryClass('LibraryClassFail', '\Case\Not\Exist'); } @@ -214,14 +215,14 @@ class libraryTest extends CoreTestAbstract /** * @depends testAddLibraryWithAutoloader * @covers ::initLibrary - * @expectedException \FuzeWorks\Exception\LibraryException */ public function testAddBadAutoloader() { + $this->expectException(LibraryException::class); $this->assertInstanceOf('Application\Library\TestAddBadAutoloader', $this->libraries->get('TestAddBadAutoloader')); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_loggerTest.php b/test/core/core_loggerTest.php index 69f9577..25023d8 100644 --- a/test/core/core_loggerTest.php +++ b/test/core/core_loggerTest.php @@ -31,7 +31,7 @@ * @link http://techfuze.net/fuzeworks * @since Version 0.0.1 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Events; @@ -51,7 +51,7 @@ class loggerTest extends CoreTestAbstract protected $output; - public function setUp() + public function setUp(): void { Factory::getInstance()->config->get('error')->fuzeworks_error_reporting = false; Logger::$logs = array(); @@ -211,7 +211,7 @@ class loggerTest extends CoreTestAbstract $this->assertFalse(Logger::isEnabled()); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/core/core_pluginsTest.php b/test/core/core_pluginsTest.php index 29beb1a..6c3fd19 100644 --- a/test/core/core_pluginsTest.php +++ b/test/core/core_pluginsTest.php @@ -31,10 +31,11 @@ * @link http://techfuze.net/fuzeworks * @since Version 1.1.4 * - * @version Version 1.2.0 + * @version Version 1.3.0 */ use FuzeWorks\Core; +use FuzeWorks\Exception\PluginException; use FuzeWorks\Factory; use FuzeWorks\Plugins; @@ -52,7 +53,7 @@ class pluginTest extends CoreTestAbstract */ protected $plugins; - public function setUp() + public function setUp(): void { $this->plugins = new Plugins(); $this->plugins->init(); @@ -106,10 +107,10 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingHeader() { + $this->expectException(PluginException::class); $this->plugins->get('testMissingHeader'); } @@ -134,39 +135,39 @@ class pluginTest extends CoreTestAbstract /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testMissingPlugin() { + $this->expectException(PluginException::class); $this->plugins->get('testMissingPlugin'); } /** * @depends testMissingPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testLoadHeaderNotIPluginHeader() { + $this->expectException(PluginException::class); $this->plugins->get('TestLoadHeaderNotIPluginHeader'); } /** * @depends testLoadPlugin * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testInvalidClass() { + $this->expectException(PluginException::class); $this->plugins->get('testInvalidClass'); } /** * @covers ::get - * @expectedException FuzeWorks\Exception\PluginException */ public function testGetMissingName() { + $this->expectException(PluginException::class); $this->plugins->get(''); } @@ -174,12 +175,12 @@ class pluginTest extends CoreTestAbstract * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths - * @expectedException FuzeWorks\Exception\PluginException */ public function testDisabledPlugin() { Factory::getInstance()->config->plugins->disabled_plugins = array('TestDisabledPlugin'); $this->plugins->loadHeadersFromPluginPaths(); + $this->expectException(PluginException::class); $this->plugins->get('testDisabledPlugin'); } @@ -187,16 +188,16 @@ class pluginTest extends CoreTestAbstract * @depends testLoadPlugin * @covers ::get * @covers ::loadHeadersFromPluginPaths - * @expectedException FuzeWorks\Exception\PluginException */ public function testRunInvalidDirectory() { $this->plugins->addComponentPath('exists_not'); $this->plugins->loadHeadersFromPluginPaths(); + $this->expectException(PluginException::class); $this->plugins->get('testRunInvalidDirectory'); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/test/phpunit.xml b/test/phpunit.xml index 14749cd..5a152b6 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -15,13 +15,6 @@ - - - - - - - ../