diff --git a/composer.json b/composer.json index 2129faf7ac3..b03b67dde98 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "ext-openssl": "To use Security::encrypt() or have secure CSRF token generation." }, "require-dev": { - "phpunit/phpunit": "<6.0", + "phpunit/phpunit": "*", "cakephp/cakephp-codesniffer": "~2.1" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 809a8a70eeb..a9ba5251dbd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,6 +6,7 @@ stopOnFailure="false" syntaxCheck="false" bootstrap="./tests/bootstrap.php" + backupGlobals="true" > diff --git a/src/TestSuite/Constraint/EventFired.php b/src/TestSuite/Constraint/EventFired.php index 170f1a039d2..0223458ba3e 100644 --- a/src/TestSuite/Constraint/EventFired.php +++ b/src/TestSuite/Constraint/EventFired.php @@ -2,13 +2,13 @@ namespace Cake\TestSuite\Constraint; use Cake\Event\EventManager; -use PHPUnit_Framework_AssertionFailedError; -use PHPUnit_Framework_Constraint; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Constraint\Constraint; /** * EventFired constraint */ -class EventFired extends PHPUnit_Framework_Constraint +class EventFired extends Constraint { /** * Array of fired events @@ -28,7 +28,7 @@ public function __construct($eventManager) $this->_eventManager = $eventManager; if ($this->_eventManager->getEventList() === null) { - throw new PHPUnit_Framework_AssertionFailedError('The event manager you are asserting against is not configured to track events.'); + throw new AssertionFailedError('The event manager you are asserting against is not configured to track events.'); } } diff --git a/src/TestSuite/Constraint/EventFiredWith.php b/src/TestSuite/Constraint/EventFiredWith.php index cf5ebf86498..572907a803a 100644 --- a/src/TestSuite/Constraint/EventFiredWith.php +++ b/src/TestSuite/Constraint/EventFiredWith.php @@ -3,15 +3,15 @@ use Cake\Event\Event; use Cake\Event\EventManager; -use PHPUnit_Framework_AssertionFailedError; -use PHPUnit_Framework_Constraint; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Constraint\Constraint; /** * EventFiredWith constraint * * Another glorified in_array check */ -class EventFiredWith extends PHPUnit_Framework_Constraint +class EventFiredWith extends Constraint { /** * Array of fired events @@ -49,7 +49,7 @@ public function __construct($eventManager, $dataKey, $dataValue) $this->_dataValue = $dataValue; if ($this->_eventManager->getEventList() === null) { - throw new PHPUnit_Framework_AssertionFailedError('The event manager you are asserting against is not configured to track events.'); + throw new AssertionFailedError('The event manager you are asserting against is not configured to track events.'); } } @@ -81,7 +81,7 @@ public function matches($other) $events = $eventGroup[$other]; if (count($events) > 1) { - throw new PHPUnit_Framework_AssertionFailedError(sprintf('Event "%s" was fired %d times, cannot make data assertion', $other, count($events))); + throw new AssertionFailedError(sprintf('Event "%s" was fired %d times, cannot make data assertion', $other, count($events))); } /* @var \Cake\Event\Event $event */ diff --git a/src/TestSuite/Fixture/FixtureInjector.php b/src/TestSuite/Fixture/FixtureInjector.php index 983d40483e1..e902edc5e4c 100644 --- a/src/TestSuite/Fixture/FixtureInjector.php +++ b/src/TestSuite/Fixture/FixtureInjector.php @@ -16,17 +16,17 @@ use Cake\TestSuite\TestCase; use Exception; -use PHPUnit_Framework_AssertionFailedError; -use PHPUnit_Framework_Test; -use PHPUnit_Framework_TestListener; -use PHPUnit_Framework_TestSuite; -use PHPUnit_Framework_Warning; +use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Framework\Warning; /** * Test listener used to inject a fixture manager in all tests that * are composed inside a Test Suite */ -class FixtureInjector implements PHPUnit_Framework_TestListener +class FixtureInjector implements TestListener { /** @@ -39,7 +39,7 @@ class FixtureInjector implements PHPUnit_Framework_TestListener /** * Holds a reference to the container test suite * - * @var \PHPUnit_Framework_TestSuite + * @var \PHPUnit\Framework\TestSuite */ protected $_first; @@ -61,10 +61,10 @@ public function __construct(FixtureManager $manager) * Iterates the tests inside a test suite and creates the required fixtures as * they were expressed inside each test case. * - * @param \PHPUnit_Framework_TestSuite $suite The test suite + * @param \PHPUnit\Framework\TestSuite $suite The test suite * @return void */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + public function startTestSuite(TestSuite $suite) { if (empty($this->_first)) { $this->_first = $suite; @@ -75,10 +75,10 @@ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) * Destroys the fixtures created by the fixture manager at the end of the test * suite run * - * @param \PHPUnit_Framework_TestSuite $suite The test suite + * @param \PHPUnit\Framework\TestSuite $suite The test suite * @return void */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + public function endTestSuite(TestSuite $suite) { if ($this->_first === $suite) { $this->_fixtureManager->shutDown(); @@ -88,70 +88,70 @@ public function endTestSuite(PHPUnit_Framework_TestSuite $suite) /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test to add errors from. + * @param \PHPUnit\Framework\Test $test The test to add errors from. * @param \Exception $e The exception * @param float $time current time * @return void */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addError(Test $test, Exception $e, $time) { } /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test to add warnings from. - * @param \PHPUnit_Framework_Warning $e The warning + * @param \PHPUnit\Framework\Test $test The test to add warnings from. + * @param \PHPUnit\Framework\Warning $e The warning * @param float $time current time * @return void */ - public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) + public function addWarning(Test $test, Warning $e, $time) { } /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test case - * @param \PHPUnit_Framework_AssertionFailedError $e The failed assertion + * @param \PHPUnit\Framework\Test $test The test case + * @param \PHPUnit\Framework\AssertionFailedError $e The failed assertion * @param float $time current time * @return void */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + public function addFailure(Test $test, AssertionFailedError $e, $time) { } /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test case + * @param \PHPUnit\Framework\Test $test The test case * @param \Exception $e The incomplete test error. * @param float $time current time * @return void */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addIncompleteTest(Test $test, Exception $e, $time) { } /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test case + * @param \PHPUnit\Framework\Test $test The test case * @param \Exception $e Skipped test exception * @param float $time current time * @return void */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addSkippedTest(Test $test, Exception $e, $time) { } /** * Adds fixtures to a test case when it starts. * - * @param \PHPUnit_Framework_Test $test The test case + * @param \PHPUnit\Framework\Test $test The test case * @return void */ - public function startTest(PHPUnit_Framework_Test $test) + public function startTest(Test $test) { $test->fixtureManager = $this->_fixtureManager; if ($test instanceof TestCase) { @@ -163,11 +163,11 @@ public function startTest(PHPUnit_Framework_Test $test) /** * Unloads fixtures from the test case. * - * @param \PHPUnit_Framework_Test $test The test case + * @param \PHPUnit\Framework\Test $test The test case * @param float $time current time * @return void */ - public function endTest(PHPUnit_Framework_Test $test, $time) + public function endTest(Test $test, $time) { if ($test instanceof TestCase) { $this->_fixtureManager->unload($test); @@ -177,12 +177,12 @@ public function endTest(PHPUnit_Framework_Test $test, $time) /** * Not Implemented * - * @param \PHPUnit_Framework_Test $test The test case + * @param \PHPUnit\Framework\Test $test The test case * @param \Exception $e The exception to track * @param float $time current time * @return void */ - public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addRiskyTest(Test $test, Exception $e, $time) { } } diff --git a/src/TestSuite/IntegrationTestCase.php b/src/TestSuite/IntegrationTestCase.php index ea8f33690f1..96a2a2ffaa5 100644 --- a/src/TestSuite/IntegrationTestCase.php +++ b/src/TestSuite/IntegrationTestCase.php @@ -24,7 +24,6 @@ use Cake\View\Helper\SecureFieldTokenTrait; use Exception; use LogicException; -use PHPUnit_Exception; /** * A test case class intended to make integration tests of @@ -420,7 +419,7 @@ protected function _sendRequest($url, $method, $data = []) $response = $dispatcher->execute($request); $this->_requestSession = $request['session']; $this->_response = $response; - } catch (PHPUnit_Exception $e) { + } catch (\PHPUnit\Exception $e) { throw $e; } catch (DatabaseException $e) { throw $e; diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index ff761582129..4bf8238069f 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -24,12 +24,12 @@ use Cake\TestSuite\Constraint\EventFiredWith; use Cake\Utility\Inflector; use Exception; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase as BaseTestCase; /** * Cake TestCase class */ -abstract class TestCase extends PHPUnit_Framework_TestCase +abstract class TestCase extends BaseTestCase { /** diff --git a/src/TestSuite/TestSuite.php b/src/TestSuite/TestSuite.php index 5648bb271ac..0f12a615057 100644 --- a/src/TestSuite/TestSuite.php +++ b/src/TestSuite/TestSuite.php @@ -17,12 +17,12 @@ namespace Cake\TestSuite; use Cake\Filesystem\Folder; -use PHPUnit_Framework_TestSuite; +use PHPUnit\Framework\TestSuite as BaseTestSuite; /** * A class to contain test cases and run them with shared fixtures */ -class TestSuite extends PHPUnit_Framework_TestSuite +class TestSuite extends BaseTestSuite { /** diff --git a/src/TestSuite/phpunit-forward-compat.php b/src/TestSuite/phpunit-forward-compat.php new file mode 100644 index 00000000000..f8db97abefb --- /dev/null +++ b/src/TestSuite/phpunit-forward-compat.php @@ -0,0 +1,12 @@ +