Skip to content

Commit

Permalink
Making sure the tests on PHP7 are testing the expected message and fa…
Browse files Browse the repository at this point in the history
…iling if no exception is thrown
  • Loading branch information
jrbasso committed Mar 29, 2015
1 parent 29be1fe commit f5930c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tests/TestCase/Auth/ControllerAuthorizeTest.php
Expand Up @@ -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());
}

Expand All @@ -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());
}
}

Expand Down
7 changes: 5 additions & 2 deletions tests/TestCase/Core/ConfigureTest.php
Expand Up @@ -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());
}

Expand All @@ -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());
}
}

Expand Down

0 comments on commit f5930c0

Please sign in to comment.