From 12ea3d98910eb97c8d4372cebacfe5a2295cce59 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 3 Feb 2017 16:09:24 +0700 Subject: [PATCH] class_alias underscored phpunit classes --- .../AbstractConsoleControllerTestCaseTest.php | 17 ++-- .../AbstractControllerTestCaseTest.php | 46 ++++++----- .../AbstractHttpControllerTestCaseTest.php | 81 ++++++++++--------- test/PHPUnit/ModuleDependenciesTest.php | 9 ++- test/PHPUnit/Util/ModuleLoaderTest.php | 8 +- 5 files changed, 92 insertions(+), 69 deletions(-) diff --git a/test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php b/test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php index 62f2318033..25af0a57e0 100644 --- a/test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php +++ b/test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php @@ -8,9 +8,14 @@ */ namespace ZendTest\Test\PHPUnit\Controller; +use PHPUnit\Framework\ExpectationFailedException; use Zend\Router\RouteMatch; use Zend\Test\PHPUnit\Controller\AbstractConsoleControllerTestCase; +if (! class_exists(ExpectationFailedException::class)) { + class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class); +} + /** * @group Zend_Test */ @@ -35,7 +40,7 @@ public function testAssertResponseStatusCode() $this->assertResponseStatusCode(0); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual status code is "0"' // check actual status code is display ); $this->assertResponseStatusCode(1); @@ -46,7 +51,7 @@ public function testAssertNotResponseStatusCode() $this->dispatch('--console'); $this->assertNotResponseStatusCode(1); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotResponseStatusCode(0); } @@ -54,7 +59,7 @@ public function testAssertResponseStatusCodeWithBadCode() { $this->dispatch('--console'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'Console status code assert value must be O (valid) or 1 (error)' ); $this->assertResponseStatusCode(2); @@ -64,7 +69,7 @@ public function testAssertNotResponseStatusCodeWithBadCode() { $this->dispatch('--console'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'Console status code assert value must be O (valid) or 1 (error)' ); $this->assertNotResponseStatusCode(2); @@ -77,7 +82,7 @@ public function testAssertConsoleOutputContains() $this->assertConsoleOutputContains('foo, bar'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "foo, bar"' // check actual content is display ); $this->assertConsoleOutputContains('baz'); @@ -88,7 +93,7 @@ public function testNotAssertConsoleOutputContains() $this->dispatch('--console'); $this->assertNotConsoleOutputContains('baz'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotConsoleOutputContains('foo'); } diff --git a/test/PHPUnit/Controller/AbstractControllerTestCaseTest.php b/test/PHPUnit/Controller/AbstractControllerTestCaseTest.php index 2066dc1e6a..fab5a643dd 100644 --- a/test/PHPUnit/Controller/AbstractControllerTestCaseTest.php +++ b/test/PHPUnit/Controller/AbstractControllerTestCaseTest.php @@ -10,7 +10,7 @@ use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamWrapper; -use PHPUnit_Framework_ExpectationFailedException; +use PHPUnit\Framework\ExpectationFailedException; use RuntimeException; use Zend\Console\Console; use Zend\Mvc\Application; @@ -19,6 +19,10 @@ use Zend\Stdlib\ResponseInterface; use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; +if (! class_exists(ExpectationFailedException::class)) { + class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class); +} + /** * @group Zend_Test */ @@ -140,7 +144,7 @@ public function testAssertModuleName() $this->assertModuleName('BAz'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual module name is "baz"' // check actual module is display ); $this->assertModuleName('Application'); @@ -158,7 +162,7 @@ public function testAssertExceptionDetailsPresentWhenTraceErrorIsEnabled() $caught = false; try { $this->assertModuleName('Application'); - } catch (PHPUnit_Framework_ExpectationFailedException $ex) { + } catch (ExpectationFailedException $ex) { $caught = true; $message = $ex->getMessage(); } @@ -182,7 +186,7 @@ public function testAssertExceptionDetailsNotPresentWhenTraceErrorIsDisabled() $caught = false; try { $this->assertModuleName('Application'); - } catch (PHPUnit_Framework_ExpectationFailedException $ex) { + } catch (ExpectationFailedException $ex) { $caught = true; $message = $ex->getMessage(); } @@ -199,7 +203,7 @@ public function testAssertNotModuleName() $this->dispatch('/tests'); $this->assertNotModuleName('Application'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotModuleName('baz'); } @@ -213,7 +217,7 @@ public function testAssertControllerClass() $this->assertControllerClass('indexcontroller'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual controller class is "indexcontroller"' // check actual controller class is display ); $this->assertControllerClass('Index'); @@ -224,7 +228,7 @@ public function testAssertNotControllerClass() $this->dispatch('/tests'); $this->assertNotControllerClass('Index'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotControllerClass('IndexController'); } @@ -238,7 +242,7 @@ public function testAssertControllerName() $this->assertControllerName('BAz_index'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual controller name is "baz_index"' // check actual controller name is display ); $this->assertControllerName('baz'); @@ -249,7 +253,7 @@ public function testAssertNotControllerName() $this->dispatch('/tests'); $this->assertNotControllerName('baz'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotControllerName('baz_index'); } @@ -263,7 +267,7 @@ public function testAssertActionName() $this->assertActionName('UnitTests'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual action name is "unittests"' // check actual action name is display ); $this->assertActionName('unit'); @@ -274,7 +278,7 @@ public function testAssertNotActionName() $this->dispatch('/tests'); $this->assertNotActionName('unit'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotActionName('unittests'); } @@ -288,7 +292,7 @@ public function testAssertMatchedRouteName() $this->assertMatchedRouteName('MyRoute'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual matched route name is "myroute"' // check actual matched route name is display ); $this->assertMatchedRouteName('route'); @@ -299,7 +303,7 @@ public function testAssertNotMatchedRouteName() $this->dispatch('/tests'); $this->assertNotMatchedRouteName('route'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotMatchedRouteName('myroute'); } @@ -312,56 +316,56 @@ public function testAssertNoMatchedRoute() public function testAssertNoMatchedRouteWithMatchedRoute() { $this->dispatch('/tests'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'no route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'no route matched'); $this->assertNoMatchedRoute(); } public function testControllerNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertControllerName('something'); } public function testNotControllerNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertNotControllerName('something'); } public function testActionNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertActionName('something'); } public function testNotActionNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertNotActionName('something'); } public function testMatchedRouteNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertMatchedRouteName('something'); } public function testNotMatchedRouteNameWithNoRouteMatch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertNotMatchedRouteName('something'); } public function testControllerClassWithNoRoutematch() { $this->dispatch('/invalid'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched'); + $this->setExpectedException(ExpectationFailedException::class, 'No route matched'); $this->assertControllerClass('something'); } diff --git a/test/PHPUnit/Controller/AbstractHttpControllerTestCaseTest.php b/test/PHPUnit/Controller/AbstractHttpControllerTestCaseTest.php index d69fd05511..6cbbcdbad9 100644 --- a/test/PHPUnit/Controller/AbstractHttpControllerTestCaseTest.php +++ b/test/PHPUnit/Controller/AbstractHttpControllerTestCaseTest.php @@ -8,6 +8,7 @@ */ namespace ZendTest\Test\PHPUnit\Controller; +use PHPUnit\Framework\ExpectationFailedException; use Zend\EventManager\StaticEventManager; use Zend\Mvc\MvcEvent; use Zend\Router\Http\RouteMatch; @@ -15,6 +16,10 @@ use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; use Zend\View\Model\ViewModel; +if (! class_exists(ExpectationFailedException::class)) { + class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class); +} + /** * @group Zend_Test */ @@ -39,7 +44,7 @@ public function testAssertResponseStatusCode() $this->assertResponseStatusCode(200); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual status code is "200"' // check actual code is display ); $this->assertResponseStatusCode(302); @@ -50,7 +55,7 @@ public function testAssertNotResponseStatusCode() $this->dispatch('/tests'); $this->assertNotResponseStatusCode(302); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotResponseStatusCode(200); } @@ -59,7 +64,7 @@ public function testAssertHasResponseHeader() $this->dispatch('/tests'); $this->assertHasResponseHeader('Content-Type'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertHasResponseHeader('Unknow-header'); } @@ -68,7 +73,7 @@ public function testAssertNotHasResponseHeader() $this->dispatch('/tests'); $this->assertNotHasResponseHeader('Unknow-header'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotHasResponseHeader('Content-Type'); } @@ -78,7 +83,7 @@ public function testAssertResponseHeaderContains() $this->assertResponseHeaderContains('Content-Type', 'text/html'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "text/html"' // check actual content is display ); $this->assertResponseHeaderContains('Content-Type', 'text/json'); @@ -95,7 +100,7 @@ public function testAssertNotResponseHeaderContains() $this->dispatch('/tests'); $this->assertNotResponseHeaderContains('Content-Type', 'text/json'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotResponseHeaderContains('Content-Type', 'text/html'); } @@ -111,7 +116,7 @@ public function testAssertResponseHeaderRegex() $this->assertResponseHeaderRegex('Content-Type', '#html$#'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "text/html"' // check actual content is display ); $this->assertResponseHeaderRegex('Content-Type', '#json#'); @@ -128,7 +133,7 @@ public function testAssertNotResponseHeaderRegex() $this->dispatch('/tests'); $this->assertNotResponseHeaderRegex('Content-Type', '#json#'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotResponseHeaderRegex('Content-Type', '#html$#'); } @@ -144,7 +149,7 @@ public function testAssertRedirect() $this->assertRedirect(); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual redirection is "http://www.zend.com"' // check actual redirection is display ); $this->assertNotRedirect(); @@ -155,7 +160,7 @@ public function testAssertNotRedirect() $this->dispatch('/test'); $this->assertNotRedirect(); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertRedirect(); } @@ -165,7 +170,7 @@ public function testAssertRedirectTo() $this->assertRedirectTo('http://www.zend.com'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual redirection is "http://www.zend.com"' // check actual redirection is display ); $this->assertRedirectTo('http://www.zend.fr'); @@ -176,7 +181,7 @@ public function testAssertNotRedirectTo() $this->dispatch('/redirect'); $this->assertNotRedirectTo('http://www.zend.fr'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotRedirectTo('http://www.zend.com'); } @@ -186,7 +191,7 @@ public function testAssertRedirectRegex() $this->assertRedirectRegex('#zend\.com$#'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual redirection is "http://www.zend.com"' // check actual redirection is display ); $this->assertRedirectRegex('#zend\.fr$#'); @@ -197,7 +202,7 @@ public function testAssertNotRedirectRegex() $this->dispatch('/redirect'); $this->assertNotRedirectRegex('#zend\.fr#'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotRedirectRegex('#zend\.com$#'); } @@ -206,7 +211,7 @@ public function testAssertQuery() $this->dispatch('/tests'); $this->assertQuery('form#myform'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertQuery('form#id'); } @@ -215,7 +220,7 @@ public function testAssertXpathQuery() $this->dispatch('/tests'); $this->assertXpathQuery('//form[@id="myform"]'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertXpathQuery('//form[@id="id"]'); } @@ -232,7 +237,7 @@ public function testAssertNotQuery() $this->dispatch('/tests'); $this->assertNotQuery('form#id'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotQuery('form#myform'); } @@ -241,7 +246,7 @@ public function testAssertNotXpathQuery() $this->dispatch('/tests'); $this->assertNotXpathQuery('//form[@id="id"]'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotXpathQuery('//form[@id="myform"]'); } @@ -251,7 +256,7 @@ public function testAssertQueryCount() $this->assertQueryCount('div.top', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertQueryCount('div.top', 2); @@ -263,7 +268,7 @@ public function testAssertXpathQueryCount() $this->assertXpathQueryCount('//div[@class="top"]', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertXpathQueryCount('//div[@class="top"]', 2); @@ -281,7 +286,7 @@ public function testAssertNotQueryCount() $this->assertNotQueryCount('div.top', 1); $this->assertNotQueryCount('div.top', 2); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotQueryCount('div.top', 3); } @@ -291,7 +296,7 @@ public function testAssertNotXpathQueryCount() $this->assertNotXpathQueryCount('//div[@class="top"]', 1); $this->assertNotXpathQueryCount('//div[@class="top"]', 2); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotXpathQueryCount('//div[@class="top"]', 3); } @@ -303,7 +308,7 @@ public function testAssertQueryCountMin() $this->assertQueryCountMin('div.top', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertQueryCountMin('div.top', 4); @@ -317,7 +322,7 @@ public function testAssertXpathQueryCountMin() $this->assertXpathQueryCountMin('//div[@class="top"]', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertXpathQueryCountMin('//div[@class="top"]', 4); @@ -331,7 +336,7 @@ public function testAssertQueryCountMax() $this->assertQueryCountMax('div.top', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertQueryCountMax('div.top', 2); @@ -345,7 +350,7 @@ public function testAssertXpathQueryCountMax() $this->assertXpathQueryCountMax('//div[@class="top"]', 3); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actually occurs 3 times' // check actual occurs is display ); $this->assertXpathQueryCountMax('//div[@class="top"]', 2); @@ -357,7 +362,7 @@ public function testAssertQueryContentContains() $this->assertQueryContentContains('div#content', 'foo'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException' + ExpectationFailedException::class ); $this->assertQueryContentContains('div#content', 'bar'); } @@ -368,7 +373,7 @@ public function testAssertQueryContentContainsWithSecondElement() $this->assertQueryContentContains('div#content', 'foo'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException' + ExpectationFailedException::class ); $this->assertQueryContentContains('div.top', 'bar'); } @@ -379,7 +384,7 @@ public function testAssertXpathQueryContentContains() $this->assertXpathQueryContentContains('//div[@class="top"]', 'foo'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException' + ExpectationFailedException::class ); $this->assertXpathQueryContentContains('//div[@class="top"]', 'bar'); } @@ -389,7 +394,7 @@ public function testAssertNotQueryContentContains() $this->dispatch('/tests'); $this->assertNotQueryContentContains('div#content', 'bar'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotQueryContentContains('div#content', 'foo'); } @@ -398,7 +403,7 @@ public function testAssertNotXpathQueryContentContains() $this->dispatch('/tests'); $this->assertNotXpathQueryContentContains('//div[@id="content"]', 'bar'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotXpathQueryContentContains('//div[@id="content"]', 'foo'); } @@ -408,7 +413,7 @@ public function testAssertQueryContentRegex() $this->assertQueryContentRegex('div#content', '#o{2}#'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "foo"' // check actual content is display ); $this->assertQueryContentRegex('div#content', '#o{3,}#'); @@ -420,7 +425,7 @@ public function testAssertQueryContentRegexMultipleMatches() $this->assertQueryContentRegex('div.top', '#o{2}#'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "foo"' // check actual content is display ); $this->assertQueryContentRegex('div.top', '#o{3,}#'); @@ -431,7 +436,7 @@ public function testAssertQueryContentRegexMultipleMatchesNoFalsePositive() $this->dispatch('/tests'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "foofoofoobar"' // check actual content is display ); $this->assertQueryContentRegex('div', '/foobar/'); @@ -443,7 +448,7 @@ public function testAssertXpathQueryContentRegex() $this->assertXpathQueryContentRegex('//div[@id="content"]', '#o{2}#'); $this->setExpectedException( - 'PHPUnit_Framework_ExpectationFailedException', + ExpectationFailedException::class, 'actual content is "foo"' // check actual content is display ); $this->assertXpathQueryContentRegex('//div[@id="content"]', '#o{3,}#'); @@ -454,7 +459,7 @@ public function testAssertNotQueryContentRegex() $this->dispatch('/tests'); $this->assertNotQueryContentRegex('div#content', '#o{3,}#'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotQueryContentRegex('div#content', '#o{2}#'); } @@ -463,7 +468,7 @@ public function testAssertNotXpathQueryContentRegex() $this->dispatch('/tests'); $this->assertNotXpathQueryContentRegex('//div[@id="content"]', '#o{3,}#'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotXpathQueryContentRegex('//div[@id="content"]', '#o{2}#'); } @@ -758,7 +763,7 @@ public function testAssertResponseReasonPhrase() $this->dispatch('/tests'); $this->assertResponseReasonPhrase('OK'); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertResponseReasonPhrase('NOT OK'); } diff --git a/test/PHPUnit/ModuleDependenciesTest.php b/test/PHPUnit/ModuleDependenciesTest.php index 8c320821ab..e1ed1403bf 100644 --- a/test/PHPUnit/ModuleDependenciesTest.php +++ b/test/PHPUnit/ModuleDependenciesTest.php @@ -9,8 +9,13 @@ namespace ZendTest\Test\PHPUnit; +use PHPUnit\Framework\ExpectationFailedException; use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; +if (! class_exists(ExpectationFailedException::class)) { + class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class); +} + /** * @group Zend_Test */ @@ -26,7 +31,7 @@ public function testDependenciesModules() $this->assertEquals(true, $sm->has('BarObject')); $this->assertModulesLoaded(['Foo', 'Bar']); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertModulesLoaded(['Foo', 'Bar', 'Unknow']); } @@ -40,7 +45,7 @@ public function testBadDependenciesModules() $this->assertEquals(true, $sm->has('BarObject')); $this->assertNotModulesLoaded(['Foo']); - $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException'); + $this->setExpectedException(ExpectationFailedException::class); $this->assertNotModulesLoaded(['Foo', 'Bar']); } } diff --git a/test/PHPUnit/Util/ModuleLoaderTest.php b/test/PHPUnit/Util/ModuleLoaderTest.php index 95266d3935..8bc8b36097 100644 --- a/test/PHPUnit/Util/ModuleLoaderTest.php +++ b/test/PHPUnit/Util/ModuleLoaderTest.php @@ -8,10 +8,14 @@ */ namespace ZendTest\Test\PHPUnit\Util; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Zend\Test\Util\ModuleLoader; -class ModuleLoaderTest extends PHPUnit_Framework_TestCase +if (! class_exists(TestCase::class)) { + class_alias(\PHPUnit_Framework_TestCase::class, TestCase::class); +} + +class ModuleLoaderTest extends TestCase { public function tearDownCacheDir() {