diff --git a/tests/TestCase/Auth/ControllerAuthorizeTest.php b/tests/TestCase/Auth/ControllerAuthorizeTest.php index 2588b6b9e42..38bcf8560fa 100644 --- a/tests/TestCase/Auth/ControllerAuthorizeTest.php +++ b/tests/TestCase/Auth/ControllerAuthorizeTest.php @@ -52,7 +52,8 @@ public function testControllerTypeError() { $this->skipIf(PHP_VERSION_ID >= 70000); - $this->setExpectedException('PHPUnit_Framework_Error'); + $message = '/^Argument 1 passed to Cake\\\Auth\\\ControllerAuthorize::controller\(\) must be an instance of Cake\\\Controller\\\Controller, instance of stdClass given.*/'; + $this->setExpectedExceptionRegExp('PHPUnit_Framework_Error', $message); $this->auth->controller(new \stdClass()); } @@ -65,8 +66,10 @@ public function testControllerTypeErrorPhp7() try { $this->auth->controller(new \stdClass()); + $this->fail(); } catch (\BaseException $e) { - $this->assertTrue(true); + $expectedMessage = 'Argument 1 passed to Cake\Auth\ControllerAuthorize::controller() must be an instance of Cake\Controller\Controller, instance of stdClass given'; + $this->assertContains($expectedMessage, $e->getMessage()); } } diff --git a/tests/TestCase/Core/ConfigureTest.php b/tests/TestCase/Core/ConfigureTest.php index 41bde83012b..2a5f590aa61 100644 --- a/tests/TestCase/Core/ConfigureTest.php +++ b/tests/TestCase/Core/ConfigureTest.php @@ -469,7 +469,8 @@ public function testEngineExceptionOnIncorrectClass() { $this->skipIf(PHP_VERSION_ID >= 70000); - $this->setExpectedException('PHPUnit_Framework_Error'); + $message = '/^Argument 2 passed to Cake\\\Core\\\Configure::config\(\) must implement interface Cake\\\Core\\\Configure\\\ConfigEngineInterface, instance of stdClass given.*/'; + $this->setExpectedExceptionRegExp('PHPUnit_Framework_Error', $message); Configure::config('test', new \stdClass()); } @@ -484,8 +485,10 @@ public function testEngineExceptionOnIncorrectClassPhp7() try { Configure::config('test', new \stdClass()); + $this->fail(); } catch (\BaseException $e) { - $this->assertTrue(true); + $expectedMessage = 'Argument 2 passed to Cake\Core\Configure::config() must implement interface Cake\Core\Configure\ConfigEngineInterface, instance of stdClass given'; + $this->assertContains($expectedMessage, $e->getMessage()); } }