From b1417587ad2ffb91e1be0e6eef434dc72662ab3b Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 31 Dec 2022 13:13:42 +0900 Subject: [PATCH] test: Replace deprecated @expectedException* to $this->expectException*() --- lib/Cake/Test/Case/Cache/CacheTest.php | 6 +-- .../Test/Case/Configure/IniReaderTest.php | 6 +-- .../Test/Case/Configure/PhpReaderTest.php | 8 ++-- .../Case/Console/ConsoleOptionParserTest.php | 14 +++---- .../Helper/ProgressShellHelperTest.php | 2 +- lib/Cake/Test/Case/Console/ShellTest.php | 2 +- .../Test/Case/Console/TaskCollectionTest.php | 2 +- .../Controller/Component/Acl/DbAclTest.php | 2 +- .../Controller/Component/AclComponentTest.php | 4 +- .../Component/Auth/BasicAuthenticateTest.php | 4 +- .../Auth/ControllerAuthorizeTest.php | 2 +- .../Component/Auth/DigestAuthenticateTest.php | 8 ++-- .../Component/AuthComponentTest.php | 11 +++--- .../Component/PaginatorComponentTest.php | 6 +-- .../Component/RequestHandlerComponentTest.php | 2 +- .../Component/SecurityComponentTest.php | 38 +++++++++---------- .../Controller/ComponentCollectionTest.php | 2 +- .../Test/Case/Controller/ControllerTest.php | 30 +++++++-------- .../Case/Controller/PagesControllerTest.php | 12 +++--- lib/Cake/Test/Case/Core/CakePluginTest.php | 4 +- lib/Cake/Test/Case/Core/ConfigureTest.php | 4 +- lib/Cake/Test/Case/I18n/I18nTest.php | 2 +- lib/Cake/Test/Case/Log/CakeLogTest.php | 14 +++---- .../Test/Case/Log/LogEngineCollectionTest.php | 2 +- .../Model/Behavior/TranslateBehaviorTest.php | 2 +- .../Case/Model/BehaviorCollectionTest.php | 2 +- .../Test/Case/Model/ConnectionManagerTest.php | 4 +- .../Model/Datasource/Database/MysqlTest.php | 2 +- .../Case/Model/Datasource/DboSourceTest.php | 3 +- lib/Cake/Test/Case/Model/ModelDeleteTest.php | 2 +- .../Test/Case/Model/ModelIntegrationTest.php | 2 +- lib/Cake/Test/Case/Model/ModelReadTest.php | 6 +-- .../Test/Case/Network/CakeRequestTest.php | 2 +- .../Test/Case/Network/CakeResponseTest.php | 18 ++++----- lib/Cake/Test/Case/Network/CakeSocketTest.php | 12 +++--- .../Test/Case/Network/Email/CakeEmailTest.php | 23 ++++++----- .../Case/Network/Email/SmtpTransportTest.php | 32 ++++++++-------- .../Case/Network/Http/HttpResponseTest.php | 2 +- .../Test/Case/Network/Http/HttpSocketTest.php | 6 +-- lib/Cake/Test/Case/Routing/DispatcherTest.php | 22 +++++------ lib/Cake/Test/Case/Routing/RouterTest.php | 8 ++-- .../Test/Case/TestSuite/CakeTestCaseTest.php | 4 +- .../Case/TestSuite/CakeTestFixtureTest.php | 2 +- .../Case/TestSuite/ControllerTestCaseTest.php | 2 +- lib/Cake/Test/Case/Utility/CakeNumberTest.php | 2 +- .../Test/Case/Utility/ClassRegistryTest.php | 4 +- lib/Cake/Test/Case/Utility/DebuggerTest.php | 2 +- lib/Cake/Test/Case/Utility/FolderTest.php | 4 +- lib/Cake/Test/Case/Utility/HashTest.php | 8 ++-- .../Case/Utility/ObjectCollectionTest.php | 2 +- lib/Cake/Test/Case/Utility/SecurityTest.php | 12 +++--- lib/Cake/Test/Case/Utility/ValidationTest.php | 2 +- lib/Cake/Test/Case/Utility/XmlTest.php | 10 ++--- .../Test/Case/View/Helper/FlashHelperTest.php | 2 +- .../Test/Case/View/Helper/FormHelperTest.php | 2 +- .../Test/Case/View/Helper/HtmlHelperTest.php | 6 +-- .../Case/View/Helper/PaginatorHelperTest.php | 2 +- .../Test/Case/View/HelperCollectionTest.php | 4 +- lib/Cake/Test/Case/View/ViewTest.php | 14 +++---- 59 files changed, 210 insertions(+), 209 deletions(-) diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index fed9d846c..3dd3a2692 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -71,10 +71,10 @@ class CacheTest extends CakeTestCase { /** * testConfigInvalidEngine method * - * @expectedException CacheException * @return void */ public function testConfigInvalidEngine() { + $this->expectException(CacheException::class); $settings = array('engine' => 'Imaginary'); Cache::config('imaginary', $settings); } @@ -164,10 +164,10 @@ class CacheTest extends CakeTestCase { /** * test that trying to configure classes that don't extend CacheEngine fail. * - * @expectedException CacheException * @return void */ public function testAttemptingToConfigureANonCacheEngineClass() { + $this->expectException(CacheException::class); $this->getMock('StdClass', array(), array(), 'RubbishEngine'); Cache::config('Garbage', array( 'engine' => 'Rubbish' @@ -308,10 +308,10 @@ class CacheTest extends CakeTestCase { /** * testGroupConfigsThrowsException method * - * @expectedException CacheException * @return void */ public function testGroupConfigsThrowsException() { + $this->expectException(CacheException::class); Cache::groupConfigs('bogus'); } diff --git a/lib/Cake/Test/Case/Configure/IniReaderTest.php b/lib/Cake/Test/Case/Configure/IniReaderTest.php index d0ef382cd..264439233 100644 --- a/lib/Cake/Test/Case/Configure/IniReaderTest.php +++ b/lib/Cake/Test/Case/Configure/IniReaderTest.php @@ -166,10 +166,10 @@ class IniReaderTest extends CakeTestCase { /** * Test an exception is thrown by reading files that exist without .ini extension. * - * @expectedException ConfigureException * @return void */ public function testReadWithExistentFileWithoutExtension() { + $this->expectException(ConfigureException::class); $reader = new IniReader($this->path); $reader->read('no_ini_extension'); } @@ -177,10 +177,10 @@ class IniReaderTest extends CakeTestCase { /** * Test an exception is thrown by reading files that don't exist. * - * @expectedException ConfigureException * @return void */ public function testReadWithNonExistentFile() { + $this->expectException(ConfigureException::class); $reader = new IniReader($this->path); $reader->read('fake_values'); } @@ -199,10 +199,10 @@ class IniReaderTest extends CakeTestCase { /** * Test reading keys with ../ doesn't work. * - * @expectedException ConfigureException * @return void */ public function testReadWithDots() { + $this->expectException(ConfigureException::class); $reader = new IniReader($this->path); $reader->read('../empty'); } diff --git a/lib/Cake/Test/Case/Configure/PhpReaderTest.php b/lib/Cake/Test/Case/Configure/PhpReaderTest.php index 1efca01fe..4c5c65f14 100644 --- a/lib/Cake/Test/Case/Configure/PhpReaderTest.php +++ b/lib/Cake/Test/Case/Configure/PhpReaderTest.php @@ -73,10 +73,10 @@ class PhpReaderTest extends CakeTestCase { /** * Test an exception is thrown by reading files that exist without .php extension. * - * @expectedException ConfigureException * @return void */ public function testReadWithExistentFileWithoutExtension() { + $this->expectException(ConfigureException::class); $reader = new PhpReader($this->path); $reader->read('no_php_extension'); } @@ -84,10 +84,10 @@ class PhpReaderTest extends CakeTestCase { /** * Test an exception is thrown by reading files that don't exist. * - * @expectedException ConfigureException * @return void */ public function testReadWithNonExistentFile() { + $this->expectException(ConfigureException::class); $reader = new PhpReader($this->path); $reader->read('fake_values'); } @@ -95,10 +95,10 @@ class PhpReaderTest extends CakeTestCase { /** * Test reading an empty file. * - * @expectedException ConfigureException * @return void */ public function testReadEmptyFile() { + $this->expectException(ConfigureException::class); $reader = new PhpReader($this->path); $reader->read('empty'); } @@ -106,10 +106,10 @@ class PhpReaderTest extends CakeTestCase { /** * Test reading keys with ../ doesn't work. * - * @expectedException ConfigureException * @return void */ public function testReadWithDots() { + $this->expectException(ConfigureException::class); $reader = new PhpReader($this->path); $reader->read('../empty'); } diff --git a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php index 77ab9d698..3be8d9672 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php @@ -159,10 +159,10 @@ class ConsoleOptionParserTest extends CakeTestCase { * Test that adding an option using a two letter short value causes an exception. * As they will not parse correctly. * - * @expectedException ConsoleException * @return void */ public function testAddOptionShortOneLetter() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addOption('test', array('short' => 'te')); } @@ -257,10 +257,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test parsing options that do not exist. * - * @expectedException ConsoleException * @return void */ public function testOptionThatDoesNotExist() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addOption('no-commit', array('boolean' => true)); @@ -270,10 +270,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test parsing short options that do not exist. * - * @expectedException ConsoleException * @return void */ public function testShortOptionThatDoesNotExist() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addOption('no-commit', array('boolean' => true)); @@ -283,10 +283,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that options with choices enforce them. * - * @expectedException ConsoleException * @return void */ public function testOptionWithChoices() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addOption('name', array('choices' => array('mark', 'jose'))); @@ -372,10 +372,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test parsing arguments. * - * @expectedException ConsoleException * @return void */ public function testParseArgumentTooMany() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addArgument('name', array('help' => 'An argument')) ->addArgument('other'); @@ -403,10 +403,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that when there are not enough arguments an exception is raised * - * @expectedException ConsoleException * @return void */ public function testPositionalArgNotEnough() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addArgument('name', array('required' => true)) ->addArgument('other', array('required' => true)); @@ -417,10 +417,10 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that arguments with choices enforce them. * - * @expectedException ConsoleException * @return void */ public function testPositionalArgWithChoices() { + $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); $parser->addArgument('name', array('choices' => array('mark', 'jose'))) ->addArgument('alias', array('choices' => array('cowboy', 'samurai'))) diff --git a/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php b/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php index bda4a80cd..03e9c6dc5 100644 --- a/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php +++ b/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php @@ -37,10 +37,10 @@ class ProgressShellHelperTest extends CakeTestCase { /** * Test that a callback is required.* * - * @expectedException \RuntimeException * @return void */ public function testOutputFailure() { + $this->expectException(\RuntimeException::class); $this->helper->output(array('not a callback')); } diff --git a/lib/Cake/Test/Case/Console/ShellTest.php b/lib/Cake/Test/Case/Console/ShellTest.php index 3f4da6ed1..2617320e6 100644 --- a/lib/Cake/Test/Case/Console/ShellTest.php +++ b/lib/Cake/Test/Case/Console/ShellTest.php @@ -1014,10 +1014,10 @@ TEXT; /** * Test getting an invalid helper * - * @expectedException RunTimeException * @return void */ public function testGetInvalidHelper() { + $this->expectException(RunTimeException::class); $this->Shell->helper("tomato"); } diff --git a/lib/Cake/Test/Case/Console/TaskCollectionTest.php b/lib/Cake/Test/Case/Console/TaskCollectionTest.php index 34cb734d4..8444427ce 100644 --- a/lib/Cake/Test/Case/Console/TaskCollectionTest.php +++ b/lib/Cake/Test/Case/Console/TaskCollectionTest.php @@ -84,10 +84,10 @@ class TaskCollectionTest extends CakeTestCase { /** * test missingtask exception * - * @expectedException MissingTaskException * @return void */ public function testLoadMissingTask() { + $this->expectException(MissingTaskException::class); $this->Tasks->load('ThisTaskShouldAlwaysBeMissing'); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php index 6654b3228..57d485408 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php @@ -291,10 +291,10 @@ class DbAclTest extends CakeTestCase { /** * Test that allow() with an invalid permission name triggers an error. * - * @expectedException CakeException * @return void */ public function testAllowInvalidPermission() { + $this->expectException(CakeException::class); $this->assertFalse($this->Acl->allow('Micheal', 'tpsReports', 'derp')); } diff --git a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php index b72784778..f59ce2930 100644 --- a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php @@ -55,10 +55,10 @@ class AclComponentTest extends CakeTestCase { * test that constructor throws an exception when Acl.classname is a * non-existent class * - * @expectedException CakeException * @return void */ public function testConstrutorException() { + $this->expectException(CakeException::class); Configure::write('Acl.classname', 'AclClassNameThatDoesNotExist'); $Collection = new ComponentCollection(); new AclComponent($Collection); @@ -80,10 +80,10 @@ class AclComponentTest extends CakeTestCase { /** * test that adapter() whines when the class does not implement AclInterface * - * @expectedException CakeException * @return void */ public function testAdapterException() { + $this->expectException(CakeException::class); $thing = new StdClass(); $this->Acl->adapter($thing); } diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index b9d007da7..7da3634fa 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -298,11 +298,11 @@ class BasicAuthenticateTest extends CakeTestCase { /** * test scope failure. * - * @expectedException UnauthorizedException - * @expectedExceptionCode 401 * @return void */ public function testAuthenticateFailReChallenge() { + $this->expectException(UnauthorizedException::class); + $this->expectExceptionCode(401); $this->auth->settings['scope'] = array('user' => 'nate'); $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index 7523b6436..a06c40fb8 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -63,10 +63,10 @@ class ControllerAuthorizeTest extends CakeTestCase { /** * testControllerErrorOnMissingMethod * - * @expectedException CakeException * @return void */ public function testControllerErrorOnMissingMethod() { + $this->expectException(CakeException::class); $this->auth->controller(new Controller()); } diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php index 1f301a1c4..d7fcd63ac 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php @@ -106,11 +106,11 @@ class DigestAuthenticateTest extends CakeTestCase { /** * test the authenticate method * - * @expectedException UnauthorizedException - * @expectedExceptionCode 401 * @return void */ public function testAuthenticateWrongUsername() { + $this->expectException(UnauthorizedException::class); + $this->expectExceptionCode(401); $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); @@ -183,11 +183,11 @@ DIGEST; /** * test scope failure. * - * @expectedException UnauthorizedException - * @expectedExceptionCode 401 * @return void */ public function testAuthenticateFailReChallenge() { + $this->expectException(UnauthorizedException::class); + $this->expectExceptionCode(401); $this->auth->settings['scope'] = array('user' => 'nate'); $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 277f45f51..2d6af32cd 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -566,10 +566,10 @@ class AuthComponentTest extends CakeTestCase { } /** - * @expectedException CakeException * @return void */ public function testIsAuthorizedMissingFile() { + $this->expectException(CakeException::class); $this->Controller->Auth->authorize = 'Missing'; $this->Controller->Auth->isAuthorized(array('User' => array('id' => 1))); } @@ -644,10 +644,10 @@ class AuthComponentTest extends CakeTestCase { } /** - * @expectedException CakeException * @return void */ public function testLoadAuthenticateNoFile() { + $this->expectException(CakeException::class); $this->Controller->Auth->authenticate = 'Missing'; $this->Controller->Auth->identify($this->Controller->request, $this->Controller->response); } @@ -1153,10 +1153,11 @@ class AuthComponentTest extends CakeTestCase { /** * Throw ForbiddenException if AuthComponent::$unauthorizedRedirect set to false - * @expectedException ForbiddenException + * * @return void */ public function testForbiddenException() { + $this->expectException(ForbiddenException::class); $url = '/party/on'; $this->Auth->request = $CakeRequest = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); @@ -1737,11 +1738,11 @@ class AuthComponentTest extends CakeTestCase { /** * testStatelessAuthNoRedirect method * - * @expectedException UnauthorizedException - * @expectedExceptionCode 401 * @return void */ public function testStatelessAuthNoRedirect() { + $this->expectException(UnauthorizedException::class); + $this->expectExceptionCode(401); if (CakeSession::id()) { session_destroy(); CakeSession::$id = null; diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 2be53d373..b20bf6b46 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -819,10 +819,10 @@ class PaginatorComponentTest extends CakeTestCase { /** * Tests for missing models * - * @expectedException MissingModelException * @return void */ public function testPaginateMissingModel() { + $this->expectException(MissingModelException::class); $Controller = new PaginatorTestController($this->request); $Controller->constructClasses(); $Controller->Paginator->paginate('MissingModel'); @@ -1115,10 +1115,10 @@ class PaginatorComponentTest extends CakeTestCase { /** * Test that a really large page number gets clamped to the max page size. * - * @expectedException NotFoundException * @return void */ public function testOutOfRangePageNumberGetsClamped() { + $this->expectException(NotFoundException::class); $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->params['named'] = array( @@ -1132,10 +1132,10 @@ class PaginatorComponentTest extends CakeTestCase { /** * Test that a really REALLY large page number gets clamped to the max page size. * - * @expectedException NotFoundException * @return void */ public function testOutOfVeryBigPageNumberGetsClamped() { + $this->expectException(NotFoundException::class); $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->params['named'] = array( diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index dce0730a1..c79e5bd1e 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -935,10 +935,10 @@ class RequestHandlerComponentTest extends CakeTestCase { } /** - * @expectedException CakeException * @return void */ public function testAddInputTypeException() { + $this->expectException(CakeException::class); $this->RequestHandler->addInputType('csv', array('I am not callable')); } diff --git a/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php b/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php index f91897f97..5ced37351 100644 --- a/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php @@ -208,10 +208,10 @@ class SecurityComponentTest extends CakeTestCase { * Test that requests are still blackholed when controller has incorrect * visibility keyword in the blackhole callback * - * @expectedException BadRequestException * @return void */ public function testBlackholeWithBrokenCallback() { + $this->expectException(BadRequestException::class); $request = new CakeRequest('posts/index', false); $request->addParams(array( 'controller' => 'posts', 'action' => 'index') @@ -1496,10 +1496,10 @@ class SecurityComponentTest extends CakeTestCase { * test that blackhole throws an exception when the key is missing and balckHoleCallback is not set. * * @return void - * @expectedException SecurityException - * @expectedExceptionMessage Missing CSRF token */ public function testCsrfExceptionOnMissingKey() { + $this->expectException(SecurityException::class); + $this->expectExceptionMessage("Missing CSRF token"); $this->Security->validatePost = false; $this->Security->csrfCheck = true; $this->Security->blackHoleCallback = ''; @@ -1542,10 +1542,10 @@ class SecurityComponentTest extends CakeTestCase { * test that blackhole throws an exception when the keys are mismatched and balckHoleCallback is not set. * * @return void - * @expectedException SecurityException - * @expectedExceptionMessage CSRF token mismatch */ public function testCsrfExceptionOnKeyMismatch() { + $this->expectException(SecurityException::class); + $this->expectExceptionMessage("CSRF token mismatch"); $this->Security->validatePost = false; $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; @@ -1594,10 +1594,10 @@ class SecurityComponentTest extends CakeTestCase { * test that blackhole throws an exception when the key is expired and balckHoleCallback is not set * * @return void - * @expectedException SecurityException - * @expectedExceptionMessage CSRF token expired */ public function testCsrfExceptionOnExpiredKey() { + $this->expectException(SecurityException::class); + $this->expectExceptionMessage("CSRF token expired"); $this->Security->validatePost = false; $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; @@ -1761,11 +1761,11 @@ class SecurityComponentTest extends CakeTestCase { /** * test blackhole will now throw passed exception if debug enabled * - * @expectedException SecurityException - * @expectedExceptionMessage error description * @return void */ public function testBlackholeThrowsException() { + $this->expectException(SecurityException::class); + $this->expectExceptionMessage("error description"); $this->Security->blackHoleCallback = ''; $this->Security->blackHole($this->Controller, 'auth', new SecurityException('error description')); } @@ -1878,10 +1878,10 @@ class SecurityComponentTest extends CakeTestCase { * Auth required throws exception token not found * * @return void - * @expectedException AuthSecurityException - * @expectedExceptionMessage '_Token' was not found in request data. */ public function testAuthRequiredThrowsExceptionTokenNotFoundPost() { + $this->expectException(AuthSecurityException::class); + $this->expectExceptionMessage("'_Token' was not found in request data."); $this->Controller->Security->requireAuth = array('protected'); $this->Controller->request->params['action'] = 'protected'; $this->Controller->request->data = array('some-key' => 'some-value'); @@ -1892,10 +1892,10 @@ class SecurityComponentTest extends CakeTestCase { * Auth required throws exception token not found in Session * * @return void - * @expectedException AuthSecurityException - * @expectedExceptionMessage '_Token' was not found in session. */ public function testAuthRequiredThrowsExceptionTokenNotFoundSession() { + $this->expectException(AuthSecurityException::class); + $this->expectExceptionMessage("'_Token' was not found in session."); $this->Controller->Security->requireAuth = array('protected'); $this->Controller->request->params['action'] = 'protected'; $this->Controller->request->data = array('_Token' => 'not empty'); @@ -1906,10 +1906,10 @@ class SecurityComponentTest extends CakeTestCase { * Auth required throws exception controller not allowed * * @return void - * @expectedException AuthSecurityException - * @expectedExceptionMessage Controller 'NotAllowed' was not found in allowed controllers: 'Allowed, AnotherAllowed'. */ public function testAuthRequiredThrowsExceptionControllerNotAllowed() { + $this->expectException(AuthSecurityException::class); + $this->expectExceptionMessage("Controller 'NotAllowed' was not found in allowed controllers: 'Allowed, AnotherAllowed'."); $this->Controller->Security->requireAuth = array('protected'); $this->Controller->request->params['controller'] = 'NotAllowed'; $this->Controller->request->params['action'] = 'protected'; @@ -1924,10 +1924,10 @@ class SecurityComponentTest extends CakeTestCase { * Auth required throws exception controller not allowed * * @return void - * @expectedException AuthSecurityException - * @expectedExceptionMessage Action 'NotAllowed::protected' was not found in allowed actions: 'index, view'. */ public function testAuthRequiredThrowsExceptionActionNotAllowed() { + $this->expectException(AuthSecurityException::class); + $this->expectExceptionMessage("Action 'NotAllowed::protected' was not found in allowed actions: 'index, view'."); $this->Controller->Security->requireAuth = array('protected'); $this->Controller->request->params['controller'] = 'NotAllowed'; $this->Controller->request->params['action'] = 'protected'; @@ -1959,10 +1959,10 @@ class SecurityComponentTest extends CakeTestCase { * Auth required throws exception controller not allowed * * @return void - * @expectedException SecurityException - * @expectedExceptionMessage The request method must be POST */ public function testMethodsRequiredThrowsExceptionMethodNotAllowed() { + $this->expectException(SecurityException::class); + $this->expectExceptionMessage("The request method must be POST"); $_SERVER['REQUEST_METHOD'] = 'GET'; $this->Controller->Security->requirePost = array('delete'); $this->Controller->request->params['controller'] = 'Test'; diff --git a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php index da4c499dd..8c66526ca 100644 --- a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php @@ -115,10 +115,10 @@ class ComponentCollectionTest extends CakeTestCase { /** * test missingcomponent exception * - * @expectedException MissingComponentException * @return void */ public function testLoadMissingComponent() { + $this->expectException(MissingComponentException::class); $this->Components->load('ThisComponentShouldAlwaysBeMissing'); } diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index e66b44728..1aebb48e7 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -1208,11 +1208,11 @@ class ControllerTest extends CakeTestCase { /** * test postConditions raising an exception on unsafe keys. * - * @expectedException RuntimeException * @dataProvider dangerousPostConditionsProvider * @return void */ public function testPostConditionsDangerous($data) { + $this->expectException(RuntimeException::class); $request = new CakeRequest('controller_posts/index'); $Controller = new Controller($request); @@ -1406,11 +1406,11 @@ class ControllerTest extends CakeTestCase { /** * testMissingAction method * - * @expectedException MissingActionException - * @expectedExceptionMessage Action TestController::missing() could not be found. * @return void */ public function testInvokeActionMissingAction() { + $this->expectException(MissingActionException::class); + $this->expectExceptionMessage("Action TestController::missing() could not be found."); $url = new CakeRequest('test/missing'); $url->addParams(array('controller' => 'test_controller', 'action' => 'missing')); $response = $this->getMock('CakeResponse'); @@ -1422,11 +1422,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking private methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::private_m() is not directly accessible. * @return void */ public function testInvokeActionPrivate() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::private_m() is not directly accessible."); $url = new CakeRequest('test/private_m/'); $url->addParams(array('controller' => 'test_controller', 'action' => 'private_m')); $response = $this->getMock('CakeResponse'); @@ -1438,11 +1438,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking protected methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::protected_m() is not directly accessible. * @return void */ public function testInvokeActionProtected() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::protected_m() is not directly accessible."); $url = new CakeRequest('test/protected_m/'); $url->addParams(array('controller' => 'test_controller', 'action' => 'protected_m')); $response = $this->getMock('CakeResponse'); @@ -1454,11 +1454,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking hidden methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::_hidden() is not directly accessible. * @return void */ public function testInvokeActionHidden() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::_hidden() is not directly accessible."); $url = new CakeRequest('test/_hidden/'); $url->addParams(array('controller' => 'test_controller', 'action' => '_hidden')); $response = $this->getMock('CakeResponse'); @@ -1470,11 +1470,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking controller methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::redirect() is not directly accessible. * @return void */ public function testInvokeActionBaseMethods() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::redirect() is not directly accessible."); $url = new CakeRequest('test/redirect/'); $url->addParams(array('controller' => 'test_controller', 'action' => 'redirect')); $response = $this->getMock('CakeResponse'); @@ -1486,11 +1486,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking controller methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::admin_add() is not directly accessible. * @return void */ public function testInvokeActionPrefixProtection() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::admin_add() is not directly accessible."); Router::reload(); Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); @@ -1505,11 +1505,11 @@ class ControllerTest extends CakeTestCase { /** * test invoking controller methods. * - * @expectedException PrivateActionException - * @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible. * @return void */ public function testInvokeActionPrefixProtectionCasing() { + $this->expectException(PrivateActionException::class); + $this->expectExceptionMessage("Private Action TestController::Admin_add() is not directly accessible."); Router::reload(); Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); diff --git a/lib/Cake/Test/Case/Controller/PagesControllerTest.php b/lib/Cake/Test/Case/Controller/PagesControllerTest.php index d623d397f..e3fdb9212 100644 --- a/lib/Cake/Test/Case/Controller/PagesControllerTest.php +++ b/lib/Cake/Test/Case/Controller/PagesControllerTest.php @@ -54,11 +54,11 @@ class PagesControllerTest extends CakeTestCase { /** * Test that missing view renders 404 page in production * - * @expectedException NotFoundException - * @expectedExceptionCode 404 * @return void */ public function testMissingView() { + $this->expectException(NotFoundException::class); + $this->expectExceptionCode(404); Configure::write('debug', 0); $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); $Pages->display('non_existing_page'); @@ -67,11 +67,11 @@ class PagesControllerTest extends CakeTestCase { /** * Test that missing view in debug mode renders missing_view error page * - * @expectedException MissingViewException - * @expectedExceptionCode 500 * @return void */ public function testMissingViewInDebug() { + $this->expectException(MissingViewException::class); + $this->expectExceptionCode(500); Configure::write('debug', 1); $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); $Pages->display('non_existing_page'); @@ -80,11 +80,11 @@ class PagesControllerTest extends CakeTestCase { /** * Test directory traversal protection * - * @expectedException ForbiddenException - * @expectedExceptionCode 403 * @return void */ public function testDirectoryTraversalProtection() { + $this->expectException(ForbiddenException::class); + $this->expectExceptionCode(403); App::build(array( 'View' => array( CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS diff --git a/lib/Cake/Test/Case/Core/CakePluginTest.php b/lib/Cake/Test/Case/Core/CakePluginTest.php index eafd0681e..86cb13eca 100644 --- a/lib/Cake/Test/Case/Core/CakePluginTest.php +++ b/lib/Cake/Test/Case/Core/CakePluginTest.php @@ -195,9 +195,9 @@ class CakePluginTest extends CakeTestCase { * Tests that CakePlugin::load() throws an exception on unknown plugin * * @return void - * @expectedException MissingPluginException */ public function testLoadNotFound() { + $this->expectException(MissingPluginException::class); CakePlugin::load('MissingPlugin'); } @@ -219,9 +219,9 @@ class CakePluginTest extends CakeTestCase { * Tests that CakePlugin::path() throws an exception on unknown plugin * * @return void - * @expectedException MissingPluginException */ public function testPathNotFound() { + $this->expectException(MissingPluginException::class); CakePlugin::path('TestPlugin'); } diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index b11f32f14..ad4838b2b 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -293,10 +293,10 @@ class ConfigureTest extends CakeTestCase { /** * testLoad method * - * @expectedException RuntimeException * @return void */ public function testLoadExceptionOnNonExistantFile() { + $this->expectException(RuntimeException::class); Configure::config('test', new PhpReader()); Configure::load('non_existing_configuration_file', 'test'); } @@ -485,10 +485,10 @@ class ConfigureTest extends CakeTestCase { /** * testDumpNoAdapter * - * @expectedException ConfigureException * @return void */ public function testDumpNoAdapter() { + $this->expectException(ConfigureException::class); Configure::dump(TMP . 'test.php', 'does_not_exist'); } diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index 064320bfa..9db69ae0f 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -2006,10 +2006,10 @@ class I18nTest extends CakeTestCase { /** * Test that the '' domain causes exceptions. * - * @expectedException CakeException * @return void */ public function testTranslateEmptyDomain() { + $this->expectException(CakeException::class); I18n::translate('Plural Rule 1', null, ''); } diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 53becfe65..5e804e4cb 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -72,10 +72,10 @@ class CakeLogTest extends CakeTestCase { /** * test all the errors from failed logger imports * - * @expectedException CakeLogException * @return void */ public function testImportingLoggerFailure() { + $this->expectException(CakeLogException::class); CakeLog::config('fail', array()); } @@ -106,20 +106,20 @@ class CakeLogTest extends CakeTestCase { /** * test config() with invalid key name * - * @expectedException CakeLogException * @return void */ public function testInvalidKeyName() { + $this->expectException(CakeLogException::class); CakeLog::config('1nv', array('engine' => 'File')); } /** * test that loggers have to implement the correct interface. * - * @expectedException CakeLogException * @return void */ public function testNotImplementingInterface() { + $this->expectException(CakeLogException::class); CakeLog::config('fail', array('engine' => 'stdClass')); } @@ -256,10 +256,10 @@ class CakeLogTest extends CakeTestCase { /** * test enable * - * @expectedException CakeLogException * @return void */ public function testStreamEnable() { + $this->expectException(CakeLogException::class); CakeLog::config('spam', array( 'engine' => 'File', 'file' => 'spam', @@ -272,10 +272,10 @@ class CakeLogTest extends CakeTestCase { /** * test disable * - * @expectedException CakeLogException * @return void */ public function testStreamDisable() { + $this->expectException(CakeLogException::class); CakeLog::config('spam', array( 'engine' => 'File', 'file' => 'spam', @@ -290,20 +290,20 @@ class CakeLogTest extends CakeTestCase { /** * test enabled() invalid stream * - * @expectedException CakeLogException * @return void */ public function testStreamEnabledInvalid() { + $this->expectException(CakeLogException::class); CakeLog::enabled('bogus_stream'); } /** * test disable invalid stream * - * @expectedException CakeLogException * @return void */ public function testStreamDisableInvalid() { + $this->expectException(CakeLogException::class); CakeLog::disable('bogus_stream'); } diff --git a/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php b/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php index 5e89c6f52..9cda882a8 100644 --- a/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php +++ b/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php @@ -79,9 +79,9 @@ class LogEngineCollectionTest extends CakeTestCase { * test load with invalid Log * * @return void - * @expectedException CakeLogException */ public function testLoadInvalid() { + $this->expectException(CakeLogException::class); $result = $this->Collection->load('key', array('engine' => 'ImaginaryFile')); $this->assertInstanceOf('CakeLogInterface', $result); } diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index 8bb584954..93b5b3fad 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -1389,10 +1389,10 @@ class TranslateBehaviorTest extends CakeTestCase { /** * Test that an exception is raised when you try to over-write the name attribute. * - * @expectedException CakeException * @return void */ public function testExceptionOnNameTranslation() { + $this->expectException(CakeException::class); $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); $TestModel->bindTranslation(array('name' => 'name')); diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index f3d0fd407..a4ada23e5 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -606,10 +606,10 @@ class BehaviorCollectionTest extends CakeTestCase { /** * test that attaching a non existent Behavior triggers a cake error. * - * @expectedException MissingBehaviorException * @return void */ public function testInvalidBehaviorCausingCakeError() { + $this->expectException(MissingBehaviorException::class); $Apple = new Apple(); $Apple->Behaviors->load('NoSuchBehavior'); } diff --git a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php index cab41d425..f6e046638 100644 --- a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php +++ b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php @@ -75,9 +75,9 @@ class ConnectionManagerTest extends CakeTestCase { * testGetDataSourceException() method * * @return void - * @expectedException MissingDatasourceConfigException */ public function testGetDataSourceException() { + $this->expectException(MissingDatasourceConfigException::class); ConnectionManager::getDataSource('non_existent_source'); } @@ -223,9 +223,9 @@ class ConnectionManagerTest extends CakeTestCase { * testLoadDataSourceException() method * * @return void - * @expectedException MissingDatasourceException */ public function testLoadDataSourceException() { + $this->expectException(MissingDatasourceException::class); $connection = array('classname' => 'NonExistentDataSource', 'filename' => 'non_existent'); ConnectionManager::loadDataSource($connection); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index d7afb7132..e74eacd26 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -3977,10 +3977,10 @@ SQL; } /** - * @expectedException MissingConnectionException * @return void */ public function testExceptionOnBrokenConnection() { + $this->expectException(MissingConnectionException::class); new Mysql(array( 'driver' => 'mysql', 'host' => 'imaginary_host', diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 75744b4e9..6e64d7ffe 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -679,10 +679,11 @@ class DboSourceTest extends CakeTestCase { } /** - * @expectedException PDOException + * * @return void */ public function testDirectCallThrowsException() { + $this->expectException(PDOException::class); $this->db->query('directCall', array(), $this->Model); } diff --git a/lib/Cake/Test/Case/Model/ModelDeleteTest.php b/lib/Cake/Test/Case/Model/ModelDeleteTest.php index 4f7abbc32..cc0dbb879 100644 --- a/lib/Cake/Test/Case/Model/ModelDeleteTest.php +++ b/lib/Cake/Test/Case/Model/ModelDeleteTest.php @@ -438,10 +438,10 @@ class ModelDeleteTest extends BaseModelTest { /** * testDeleteAllUnknownColumn method * - * @expectedException PDOException * @return void */ public function testDeleteAllUnknownColumn() { + $this->expectException(PDOException::class); $this->loadFixtures('Article'); $TestModel = new Article(); $result = $TestModel->deleteAll(array('Article.non_existent_field' => 999)); diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 30eeb92f3..7f4107d34 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -140,10 +140,10 @@ class ModelIntegrationTest extends BaseModelTest { /** * Tests that creating a model with no existent database table associated will throw an exception * - * @expectedException MissingTableException * @return void */ public function testMissingTable() { + $this->expectException(MissingTableException::class); $Article = new ArticleB(false, uniqid()); $Article->schema(); } diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index 84bdaf1ec..d2c707977 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -517,10 +517,10 @@ class ModelReadTest extends BaseModelTest { /** * testParameterMismatch method * - * @expectedException PDOException * @return void */ public function testParameterMismatch() { + $this->expectException(PDOException::class); $this->skipIf($this->db instanceof Sqlite, 'Sqlite does not accept real prepared statements, no way to check this'); $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag'); $Article = new Article(); @@ -536,10 +536,10 @@ class ModelReadTest extends BaseModelTest { /** * testVeryStrangeUseCase method * - * @expectedException PDOException * @return void */ public function testVeryStrangeUseCase() { + $this->expectException(PDOException::class); $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag'); $Article = new Article(); @@ -5412,10 +5412,10 @@ class ModelReadTest extends BaseModelTest { /** * testCallbackSourceChangeUnknownDatasource method * - * @expectedException MissingDatasourceConfigException * @return void */ public function testCallbackSourceChangeUnknownDatasource() { + $this->expectException(MissingDatasourceConfigException::class); $this->loadFixtures('Post', 'Author'); $TestModel = new Post(); $this->assertFalse($TestModel->find('all', array('connection' => 'foo'))); diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 3a1fb082f..da750cac6 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -978,10 +978,10 @@ class CakeRequestTest extends CakeTestCase { /** * Test __call exceptions * - * @expectedException CakeException * @return void */ public function testMagicCallExceptionOnUnknownMethod() { + $this->expectException(CakeException::class); $request = new CakeRequest('some/path'); $request->IamABanana(); } diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 6ad9f9950..5fdcb6192 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -113,10 +113,10 @@ class CakeResponseTest extends CakeTestCase { /** * Tests the statusCode method * - * @expectedException CakeException * @return void */ public function testStatusCode() { + $this->expectException(CakeException::class); $response = new CakeResponse(); $this->assertEquals(200, $response->statusCode()); $response->statusCode(404); @@ -402,10 +402,10 @@ class CakeResponseTest extends CakeTestCase { /** * Tests the httpCodes method * - * @expectedException CakeException * @return void */ public function testHttpCodes() { + $this->expectException(CakeException::class); $response = new CakeResponse(); $result = $response->httpCodes(); $this->assertEquals(41, count($result)); @@ -1162,10 +1162,10 @@ class CakeResponseTest extends CakeTestCase { /** * testFileNotFound * - * @expectedException NotFoundException * @return void */ public function testFileNotFound() { + $this->expectException(NotFoundException::class); $response = new CakeResponse(); $response->file('/some/missing/folder/file.jpg'); } @@ -1173,11 +1173,11 @@ class CakeResponseTest extends CakeTestCase { /** * test file with ../ * - * @expectedException NotFoundException - * @expectedExceptionMessage The requested file contains `..` and will not be read. * @return void */ public function testFileWithForwardSlashPathTraversal() { + $this->expectException(NotFoundException::class); + $this->expectExceptionMessage("The requested file contains `..` and will not be read."); $response = new CakeResponse(); $response->file('my/../cat.gif'); } @@ -1185,11 +1185,11 @@ class CakeResponseTest extends CakeTestCase { /** * test file with ..\ * - * @expectedException NotFoundException - * @expectedExceptionMessage The requested file contains `..` and will not be read. * @return void */ public function testFileWithBackwardSlashPathTraversal() { + $this->expectException(NotFoundException::class); + $this->expectExceptionMessage("The requested file contains `..` and will not be read."); $response = new CakeResponse(); $response->file('my\..\cat.gif'); } @@ -1198,11 +1198,11 @@ class CakeResponseTest extends CakeTestCase { * Although unlikely, a file may contain dots in its filename. * This should be allowed, as long as the dots doesn't specify a path (../ or ..\) * - * @expectedException NotFoundException - * @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable# * @return void */ public function testFileWithDotsInFilename() { + $this->expectException(NotFoundException::class); + $this->expectExceptionMessageMatches('#The requested file .+my/Some..cat.gif was not found or not readable#'); $response = new CakeResponse(); $response->file('my/Some..cat.gif'); } diff --git a/lib/Cake/Test/Case/Network/CakeSocketTest.php b/lib/Cake/Test/Case/Network/CakeSocketTest.php index 557c1a8b0..9df37c396 100644 --- a/lib/Cake/Test/Case/Network/CakeSocketTest.php +++ b/lib/Cake/Test/Case/Network/CakeSocketTest.php @@ -118,10 +118,10 @@ class CakeSocketTest extends CakeTestCase { * testInvalidConnection method * * @dataProvider invalidConnections - * @expectedException SocketException * @return void */ public function testInvalidConnection($data) { + $this->expectException(SocketException::class); $this->Socket->config = array_merge($this->Socket->config, $data); $this->Socket->connect(); } @@ -238,10 +238,10 @@ class CakeSocketTest extends CakeTestCase { /** * testEncrypt * - * @expectedException SocketException * @return void */ public function testEnableCryptoSocketExceptionNoSsl() { + $this->expectException(SocketException::class); $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); $configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1); @@ -254,10 +254,10 @@ class CakeSocketTest extends CakeTestCase { /** * testEnableCryptoSocketExceptionNoTls * - * @expectedException SocketException * @return void */ public function testEnableCryptoSocketExceptionNoTls() { + $this->expectException(SocketException::class); $configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1); // testing exception on no ssl socket server for ssl and tls methods @@ -303,10 +303,10 @@ class CakeSocketTest extends CakeTestCase { /** * testEnableCryptoBadMode * - * @expectedException InvalidArgumentException * @return void */ public function testEnableCryptoBadMode() { + $this->expectException(InvalidArgumentException::class); // testing wrong encryption mode $this->_connectSocketToSslTls(); $this->Socket->enableCrypto('doesntExistMode', 'server'); @@ -342,10 +342,10 @@ class CakeSocketTest extends CakeTestCase { /** * testEnableCryptoExceptionEnableTwice * - * @expectedException SocketException * @return void */ public function testEnableCryptoExceptionEnableTwice() { + $this->expectException(SocketException::class); // testing on tls server $this->_connectSocketToSslTls(); $this->Socket->enableCrypto('tls', 'client'); @@ -355,10 +355,10 @@ class CakeSocketTest extends CakeTestCase { /** * testEnableCryptoExceptionDisableTwice * - * @expectedException SocketException * @return void */ public function testEnableCryptoExceptionDisableTwice() { + $this->expectException(SocketException::class); // testing on tls server $this->_connectSocketToSslTls(); $this->Socket->enableCrypto('tls', 'client', false); diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index da70d7d4c..5783f9a10 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -334,33 +334,33 @@ class CakeEmailTest extends CakeTestCase { /** * testBuildInvalidData * - * @expectedException SocketException - * @expectedExceptionMessage The email set for "_to" is empty. * @return void */ public function testInvalidEmail() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("The email set for \"_to\" is empty."); $this->CakeEmail->to(''); } /** * testBuildInvalidData * - * @expectedException SocketException - * @expectedExceptionMessage Invalid email set for "_from". You passed "cake.@" * @return void */ public function testInvalidFrom() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("Invalid email set for \"_from\". You passed \"cake.@\""); $this->CakeEmail->from('cake.@'); } /** * testBuildInvalidData * - * @expectedException SocketException - * @expectedExceptionMessage Invalid email set for "_to". You passed "1" * @return void */ public function testInvalidEmailAdd() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("Invalid email set for \"_to\". You passed \"1\""); $this->CakeEmail->addTo('1'); } @@ -432,11 +432,10 @@ class CakeEmailTest extends CakeTestCase { * Tests that it is possible to unset the email pattern and make use of filter_var() instead. * * @return void - * - * @expectedException SocketException - * @expectedExceptionMessage Invalid email set for "_to". You passed "fail.@example.com" */ public function testUnsetEmailPattern() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("Invalid email set for \"_to\". You passed \"fail.@example.com\""); $email = new CakeEmail(); $this->assertSame(CakeEmail::EMAIL_PATTERN, $email->emailPattern()); @@ -594,9 +593,9 @@ class CakeEmailTest extends CakeTestCase { * testMessageIdInvalid method * * @return void - * @expectedException SocketException */ public function testMessageIdInvalid() { + $this->expectException(SocketException::class); $this->CakeEmail->messageId('my-email@localhost'); } @@ -776,10 +775,10 @@ class CakeEmailTest extends CakeTestCase { * testInvalidHeaders * * @dataProvider invalidHeaders - * @expectedException SocketException * @return void */ public function testInvalidHeaders($value) { + $this->expectException(SocketException::class); $this->CakeEmail->setHeaders($value); } @@ -787,10 +786,10 @@ class CakeEmailTest extends CakeTestCase { * testInvalidAddHeaders * * @dataProvider invalidHeaders - * @expectedException SocketException * @return void */ public function testInvalidAddHeaders($value) { + $this->expectException(SocketException::class); $this->CakeEmail->addHeaders($value); } diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 307b86c91..7377e88ec 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -115,11 +115,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testConnectEhloTlsOnNonTlsServer method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS. * @return void */ public function testConnectEhloTlsOnNonTlsServer() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS."); $this->SmtpTransport->config(array('tls' => true)); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); @@ -133,11 +133,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testConnectEhloNoTlsOnRequiredTlsServer method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS. * @return void */ public function testConnectEhloNoTlsOnRequiredTlsServer() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP authentication method not allowed, check if SMTP server requires TLS."); $this->SmtpTransport->config(array('tls' => false, 'username' => 'user', 'password' => 'pass')); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); @@ -167,11 +167,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testConnectFail method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP server did not accept the connection. * @return void */ public function testConnectFail() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP server did not accept the connection."); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); @@ -200,11 +200,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testAuthNotRecognized method * - * @expectedException SocketException - * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication. * @return void */ public function testAuthNotRecognized() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("AUTH command not recognized or not implemented, SMTP server may not require authentication."); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); @@ -214,11 +214,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testAuthNotImplemented method * - * @expectedException SocketException - * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication. * @return void */ public function testAuthNotImplemented() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("AUTH command not recognized or not implemented, SMTP server may not require authentication."); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read') ->will($this->returnValue("502 5.3.3 Command not implemented\r\n")); @@ -229,11 +229,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testAuthBadSequence method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP Error: 503 5.5.1 Already authenticated * @return void */ public function testAuthBadSequence() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP Error: 503 5.5.1 Already authenticated"); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read') ->will($this->returnValue("503 5.5.1 Already authenticated\r\n")); @@ -244,11 +244,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testAuthBadUsername method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP server did not accept the username. * @return void */ public function testAuthBadUsername() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP server did not accept the username."); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); @@ -260,11 +260,11 @@ class SmtpTransportTest extends CakeTestCase { /** * testAuthBadPassword method * - * @expectedException SocketException - * @expectedExceptionMessage SMTP server did not accept the password. * @return void */ public function testAuthBadPassword() { + $this->expectException(SocketException::class); + $this->expectExceptionMessage("SMTP server did not accept the password."); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index bfed552d9..928fb0dbd 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -362,10 +362,10 @@ class HttpResponseTest extends CakeTestCase { * testInvalidParseResponseData * * @dataProvider invalidParseResponseDataProvider - * @expectedException SocketException * @return void */ public function testInvalidParseResponseData($value) { + $this->expectException(SocketException::class); $this->HttpResponse->parseResponse($value); } diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 27c692444..07dfb6c87 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -624,10 +624,10 @@ class HttpSocketTest extends CakeTestCase { /** * The "*" asterisk character is only allowed for the following methods: OPTIONS. * - * @expectedException SocketException * @return void */ public function testRequestNotAllowedUri() { + $this->expectException(SocketException::class); $this->Socket->reset(); $request = array('uri' => '*', 'method' => 'GET'); $this->Socket->request($request); @@ -1358,20 +1358,20 @@ class HttpSocketTest extends CakeTestCase { /** * testBadBuildRequestLine method * - * @expectedException SocketException * @return void */ public function testBadBuildRequestLine() { + $this->expectException(SocketException::class); $this->Socket->buildRequestLine('Foo'); } /** * testBadBuildRequestLine2 method * - * @expectedException SocketException * @return void */ public function testBadBuildRequestLine2() { + $this->expectException(SocketException::class); $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); } diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 806f75efd..08d45e46f 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -738,11 +738,11 @@ class DispatcherTest extends CakeTestCase { /** * testMissingController method * - * @expectedException MissingControllerException - * @expectedExceptionMessage Controller class SomeControllerController could not be found. * @return void */ public function testMissingController() { + $this->expectException(MissingControllerException::class); + $this->expectExceptionMessage("Controller class SomeControllerController could not be found."); Router::connect('/:controller/:action/*'); $Dispatcher = new TestDispatcher(); @@ -756,11 +756,11 @@ class DispatcherTest extends CakeTestCase { /** * testMissingControllerInterface method * - * @expectedException MissingControllerException - * @expectedExceptionMessage Controller class DispatcherTestInterfaceController could not be found. * @return void */ public function testMissingControllerInterface() { + $this->expectException(MissingControllerException::class); + $this->expectExceptionMessage("Controller class DispatcherTestInterfaceController could not be found."); Router::connect('/:controller/:action/*'); $Dispatcher = new TestDispatcher(); @@ -774,11 +774,11 @@ class DispatcherTest extends CakeTestCase { /** * testMissingControllerInterface method * - * @expectedException MissingControllerException - * @expectedExceptionMessage Controller class DispatcherTestAbstractController could not be found. * @return void */ public function testMissingControllerAbstract() { + $this->expectException(MissingControllerException::class); + $this->expectExceptionMessage("Controller class DispatcherTestAbstractController could not be found."); Router::connect('/:controller/:action/*'); $Dispatcher = new TestDispatcher(); @@ -1164,11 +1164,11 @@ class DispatcherTest extends CakeTestCase { /** * testAutomaticPluginControllerMissingActionDispatch method * - * @expectedException MissingActionException - * @expectedExceptionMessage Action MyPluginController::not_here() could not be found. * @return void */ public function testAutomaticPluginControllerMissingActionDispatch() { + $this->expectException(MissingActionException::class); + $this->expectExceptionMessage("Action MyPluginController::not_here() could not be found."); Router::reload(); $Dispatcher = new TestDispatcher(); @@ -1181,12 +1181,12 @@ class DispatcherTest extends CakeTestCase { /** * testAutomaticPluginControllerMissingActionDispatch method * - * @expectedException MissingActionException - * @expectedExceptionMessage Action MyPluginController::param:value() could not be found. * @return void */ public function testAutomaticPluginControllerIndexMissingAction() { + $this->expectException(MissingActionException::class); + $this->expectExceptionMessage("Action MyPluginController::param:value() could not be found."); Router::reload(); $Dispatcher = new TestDispatcher(); @@ -1283,10 +1283,10 @@ class DispatcherTest extends CakeTestCase { /** * Tests that attaching an inexistent class as filter will throw an exception * - * @expectedException MissingDispatcherFilterException * @return void */ public function testDispatcherFilterSuscriberMissing() { + $this->expectException(MissingDispatcherFilterException::class); App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) ), App::RESET); diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 004e2ddf8..46eea437f 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2450,10 +2450,10 @@ class RouterTest extends CakeTestCase { /** * test that route classes must extend CakeRoute * - * @expectedException RouterException * @return void */ public function testCustomRouteException() { + $this->expectException(RouterException::class); Router::connect('/:controller', array(), array('routeClass' => 'CakeObject')); } @@ -2840,10 +2840,10 @@ class RouterTest extends CakeTestCase { /** * Test that route classes must extend CakeRoute * - * @expectedException RouterException * @return void */ public function testDefaultRouteException() { + $this->expectException(RouterException::class); Router::defaultRouteClass(''); Router::connect('/:controller', array()); } @@ -2851,20 +2851,20 @@ class RouterTest extends CakeTestCase { /** * Test that route classes must extend CakeRoute * - * @expectedException RouterException * @return void */ public function testSettingInvalidDefaultRouteException() { + $this->expectException(RouterException::class); Router::defaultRouteClass('CakeObject'); } /** * Test that class must exist * - * @expectedException RouterException * @return void */ public function testSettingNonExistentDefaultRouteException() { + $this->expectException(RouterException::class); Router::defaultRouteClass('NonExistentClass'); } diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index 554926d19..9232508d2 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -508,11 +508,11 @@ class CakeTestCaseTest extends CakeTestCase { /** * testGetMockForModelDoesNotExist * - * @expectedException MissingModelException - * @expectedExceptionMessage Model IDoNotExist could not be found * @return void */ public function testGetMockForModelDoesNotExist() { + $this->expectException(MissingModelException::class); + $this->expectExceptionMessage("Model IDoNotExist could not be found"); $this->getMockForModel('IDoNotExist'); } } diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index ad522f3a3..e501b50ac 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -528,10 +528,10 @@ class CakeTestFixtureTest extends CakeTestCase { /** * test the insert method with invalid fixture * - * @expectedException CakeException * @return void */ public function testInsertInvalid() { + $this->expectException(CakeException::class); $Fixture = new InvalidTestFixture(); $Fixture->insert($this->criticDb); } diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index 77671f6e1..0a9bd2b14 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -402,10 +402,10 @@ class ControllerTestCaseTest extends CakeTestCase { /** * Tests not using loaded routes during tests * - * @expectedException MissingActionException * @return void */ public function testSkipRoutes() { + $this->expectException(MissingActionException::class); Router::connect('/:controller/:action/*'); include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php'; diff --git a/lib/Cake/Test/Case/Utility/CakeNumberTest.php b/lib/Cake/Test/Case/Utility/CakeNumberTest.php index a9928aa06..aff777391 100644 --- a/lib/Cake/Test/Case/Utility/CakeNumberTest.php +++ b/lib/Cake/Test/Case/Utility/CakeNumberTest.php @@ -752,10 +752,10 @@ class CakeNumberTest extends CakeTestCase { /** * testFromReadableSize * - * @expectedException CakeException * @return void */ public function testFromReadableSizeException() { + $this->expectException(CakeException::class); $this->Number->fromReadableSize('bogus', false); } diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index 2cab08e09..6f0a2d7e8 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -326,20 +326,20 @@ class ClassRegistryTest extends CakeTestCase { /** * Test that you cannot init() an abstract class. An exception will be raised. * - * @expectedException CakeException * @return void */ public function testInitAbstractClass() { + $this->expectException(CakeException::class); ClassRegistry::init('ClassRegistryAbstractModel'); } /** * Test that you cannot init() an abstract class. A exception will be raised. * - * @expectedException CakeException * @return void */ public function testInitInterface() { + $this->expectException(CakeException::class); ClassRegistry::init('ClassRegistryInterfaceTest'); } } diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index fb63448a6..f537aca12 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -225,10 +225,10 @@ class DebuggerTest extends CakeTestCase { /** * Test that choosing a non-existent format causes an exception * - * @expectedException CakeException * @return void */ public function testOutputAsException() { + $this->expectException(CakeException::class); Debugger::outputAs('Invalid junk'); } diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 29419ac00..2c4a82d9a 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -183,10 +183,10 @@ class FolderTest extends CakeTestCase { /** * @dataProvider inPathInvalidPathArgumentDataProvider * @param string $path - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The $path argument is expected to be an absolute path. */ public function testInPathInvalidPathArgument($path) { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("The \$path argument is expected to be an absolute path."); $Folder = new Folder(); $Folder->inPath($path); } diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index fb5db2693..be6c881e6 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -248,10 +248,10 @@ class HashTest extends CakeTestCase { /** * Test get() with an invalid path * - * @expectedException InvalidArgumentException * @return void */ public function testGetInvalidPath() { + $this->expectException(InvalidArgumentException::class); Hash::get(array('one' => 'two'), new StdClass()); } @@ -1900,10 +1900,10 @@ class HashTest extends CakeTestCase { /** * test combine() giving errors on key/value length mismatches. * - * @expectedException CakeException * @return void */ public function testCombineErrorMissingValue() { + $this->expectException(CakeException::class); $data = array( array('User' => array('id' => 1, 'name' => 'mark')), array('User' => array('name' => 'jose')), @@ -1914,10 +1914,10 @@ class HashTest extends CakeTestCase { /** * test combine() giving errors on key/value length mismatches. * - * @expectedException CakeException * @return void */ public function testCombineErrorMissingKey() { + $this->expectException(CakeException::class); $data = array( array('User' => array('id' => 1, 'name' => 'mark')), array('User' => array('id' => 2)), @@ -2585,10 +2585,10 @@ class HashTest extends CakeTestCase { /** * Tests that nest() throws an InvalidArgumentException when providing an invalid input. * - * @expectedException InvalidArgumentException * @return void */ public function testNestInvalid() { + $this->expectException(InvalidArgumentException::class); $input = array( array( 'ParentCategory' => array( diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index 0624580e3..dc0c9ec92 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -342,10 +342,10 @@ class ObjectCollectionTest extends CakeTestCase { /** * test that setting modParams to an index that doesn't exist doesn't cause errors. * - * @expectedException CakeException * @return void */ public function testTriggerModParamsInvalidIndex() { + $this->expectException(CakeException::class); $this->_makeMockClasses(); $this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject); $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject); diff --git a/lib/Cake/Test/Case/Utility/SecurityTest.php b/lib/Cake/Test/Case/Utility/SecurityTest.php index ddb38b6d3..aa6d2af04 100644 --- a/lib/Cake/Test/Case/Utility/SecurityTest.php +++ b/lib/Cake/Test/Case/Utility/SecurityTest.php @@ -456,11 +456,11 @@ class SecurityTest extends CakeTestCase { /** * Test that short keys cause errors * - * @expectedException CakeException - * @expectedExceptionMessage Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long. * @return void */ public function testEncryptInvalidKey() { + $this->expectException(CakeException::class); + $this->expectExceptionMessage("Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long."); $txt = 'The quick brown fox jumped over the lazy dog.'; $key = 'this is too short'; Security::encrypt($txt, $key); @@ -494,11 +494,11 @@ class SecurityTest extends CakeTestCase { /** * Test that short keys cause errors * - * @expectedException CakeException - * @expectedExceptionMessage Invalid key for decrypt(), key must be at least 256 bits (32 bytes) long. * @return void */ public function testDecryptInvalidKey() { + $this->expectException(CakeException::class); + $this->expectExceptionMessage("Invalid key for decrypt(), key must be at least 256 bits (32 bytes) long."); $txt = 'The quick brown fox jumped over the lazy dog.'; $key = 'this is too short'; Security::decrypt($txt, $key); @@ -507,11 +507,11 @@ class SecurityTest extends CakeTestCase { /** * Test that empty data cause errors * - * @expectedException CakeException - * @expectedExceptionMessage The data to decrypt cannot be empty. * @return void */ public function testDecryptInvalidData() { + $this->expectException(CakeException::class); + $this->expectExceptionMessage("The data to decrypt cannot be empty."); $txt = ''; $key = 'This is a key that is long enough to be ok.'; Security::decrypt($txt, $key); diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 533512f25..37339eff8 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -2405,10 +2405,10 @@ class ValidationTest extends CakeTestCase { /** * testMimeTypeFalse method * - * @expectedException CakeException * @return void */ public function testMimeTypeFalse() { + $this->expectException(CakeException::class); $image = CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif'; $File = new File($image, false); $this->skipIf($File->mime(), 'mimeType can be determined, no Exception will be thrown'); diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index ee585e244..8fa7fd9ef 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -182,10 +182,10 @@ class XmlTest extends CakeTestCase { /** * Test that the readFile option disables local file parsing. * - * @expectedException XmlException * @return void */ public function testBuildFromFileWhenDisabled() { + $this->expectException(XmlException::class); $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; Xml::build($xml, array('readFile' => false)); } @@ -193,10 +193,10 @@ class XmlTest extends CakeTestCase { /** * Test that the readFile option disables local file parsing. * - * @expectedException XmlException * @return void */ public function testBuildFromUrlWhenDisabled() { + $this->expectException(XmlException::class); $xml = 'http://www.google.com'; Xml::build($xml, array('readFile' => false)); } @@ -219,20 +219,20 @@ class XmlTest extends CakeTestCase { * testBuildInvalidData * * @dataProvider invalidDataProvider - * @expectedException XmlException * @return void */ public function testBuildInvalidData($value) { + $this->expectException(XmlException::class); Xml::build($value); } /** * Test that building SimpleXmlElement with invalid XML causes the right exception. * - * @expectedException XmlException * @return void */ public function testBuildInvalidDataSimpleXml() { + $this->expectException(XmlException::class); $input = ' 'simplexml')); } @@ -1174,10 +1174,10 @@ XML; * testToArrayFail method * * @dataProvider invalidToArrayDataProvider - * @expectedException XmlException * @return void */ public function testToArrayFail($value) { + $this->expectException(XmlException::class); Xml::toArray($value); } diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php index 06940bf5f..f01d69f76 100644 --- a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -136,9 +136,9 @@ class FlashHelperTest extends CakeTestCase { /** * testFlashThrowsException * - * @expectedException UnexpectedValueException */ public function testFlashThrowsException() { + $this->expectException(UnexpectedValueException::class); CakeSession::write('Message.foo', 'bar'); $this->Flash->render('foo'); } diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 373ca0aea..2392be425 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -10918,10 +10918,10 @@ class FormHelperTest extends CakeTestCase { } /** - * @expectedException CakeException * @return void */ public function testHtml5InputException() { + $this->expectException(CakeException::class); $this->Form->email(); } diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 726520326..755ad27d5 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -580,9 +580,9 @@ class HtmlHelperTest extends CakeTestCase { * testLoadConfigWrongFile method * * @return void - * @expectedException InvalidArgumentException */ public function testBase64InvalidArgumentException() { + $this->expectException(InvalidArgumentException::class); $this->Html->request->webroot = ''; $this->Html->image('non-existent-image.png', array('base64' => true)); } @@ -2321,9 +2321,9 @@ class HtmlHelperTest extends CakeTestCase { * testLoadConfigWrongFile method * * @return void - * @expectedException ConfigureException */ public function testLoadConfigWrongFile() { + $this->expectException(ConfigureException::class); $this->Html->loadConfig('wrong_file'); } @@ -2331,9 +2331,9 @@ class HtmlHelperTest extends CakeTestCase { * testLoadConfigWrongReader method * * @return void - * @expectedException ConfigureException */ public function testLoadConfigWrongReader() { + $this->expectException(ConfigureException::class); $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS; $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); } diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index a096dd71c..ea5a02ca8 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -2811,10 +2811,10 @@ class PaginatorHelperTest extends CakeTestCase { /** * test that mock classes injected into paginatorHelper are called when using link() * - * @expectedException CakeException * @return void */ public function testMockAjaxProviderClassInjection() { + $this->expectException(CakeException::class); $mock = $this->getMock('PaginatorHelper', array(), array($this->View), 'PaginatorMockJsHelper'); $Paginator = new PaginatorHelper($this->View, array('ajax' => 'PaginatorMockJs')); $Paginator->request->params['paging'] = array( diff --git a/lib/Cake/Test/Case/View/HelperCollectionTest.php b/lib/Cake/Test/Case/View/HelperCollectionTest.php index f1919e6cc..bdcaf4c78 100644 --- a/lib/Cake/Test/Case/View/HelperCollectionTest.php +++ b/lib/Cake/Test/Case/View/HelperCollectionTest.php @@ -93,10 +93,10 @@ class HelperCollectionTest extends CakeTestCase { /** * test lazy loading of helpers * - * @expectedException MissingHelperException * @return void */ public function testLazyLoadException() { + $this->expectException(MissingHelperException::class); $this->Helpers->NotAHelper; } @@ -145,10 +145,10 @@ class HelperCollectionTest extends CakeTestCase { /** * test missinghelper exception * - * @expectedException MissingHelperException * @return void */ public function testLoadMissingHelper() { + $this->expectException(MissingHelperException::class); $this->Helpers->load('ThisHelperShouldAlwaysBeMissing'); } diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 91dba6bc9..5a9605ce2 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -399,10 +399,10 @@ class ViewTest extends CakeTestCase { * Test that plugin files with absolute file paths are scoped * to the plugin and do now allow any file path. * - * @expectedException MissingViewException * @return void */ public function testPluginGetTemplateAbsoluteFail() { + $this->expectException(MissingViewException::class); $this->Controller->viewPath = 'Pages'; $this->Controller->action = 'display'; $this->Controller->params['pass'] = array('home'); @@ -614,10 +614,10 @@ class ViewTest extends CakeTestCase { /** * Test for missing views * - * @expectedException MissingViewException * @return void */ public function testMissingView() { + $this->expectException(MissingViewException::class); $this->Controller->plugin = null; $this->Controller->name = 'Pages'; $this->Controller->viewPath = 'Pages'; @@ -631,10 +631,10 @@ class ViewTest extends CakeTestCase { /** * Test for missing theme views * - * @expectedException MissingViewException * @return void */ public function testMissingThemeView() { + $this->expectException(MissingViewException::class); $this->ThemeController->plugin = null; $this->ThemeController->name = 'Pages'; $this->ThemeController->viewPath = 'Pages'; @@ -650,10 +650,10 @@ class ViewTest extends CakeTestCase { /** * Test for missing layouts * - * @expectedException MissingLayoutException * @return void */ public function testMissingLayout() { + $this->expectException(MissingLayoutException::class); $this->Controller->plugin = null; $this->Controller->name = 'Posts'; $this->Controller->viewPath = 'Posts'; @@ -666,10 +666,10 @@ class ViewTest extends CakeTestCase { /** * Test for missing theme layouts * - * @expectedException MissingLayoutException * @return void */ public function testMissingThemeLayout() { + $this->expectException(MissingLayoutException::class); $this->ThemeController->plugin = null; $this->ThemeController->name = 'Posts'; $this->ThemeController->viewPath = 'posts'; @@ -1334,10 +1334,10 @@ class ViewTest extends CakeTestCase { /** * testBadExt method * - * @expectedException MissingViewException * @return void */ public function testBadExt() { + $this->expectException(MissingViewException::class); $this->PostsController->action = 'something'; $this->PostsController->ext = '.whatever'; @@ -1360,10 +1360,10 @@ class ViewTest extends CakeTestCase { /** * testAltBadExt method * - * @expectedException MissingViewException * @return void */ public function testAltBadExt() { + $this->expectException(MissingViewException::class); $View = new TestView($this->PostsController); $View->render('alt_ext'); }