diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php index d4e516acc..8b73f6385 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php @@ -171,9 +171,8 @@ class MemcachedEngineTest extends CakeTestCase { 'serialize' => 'invalid_serializer' ); - $this->setExpectedException( - 'CacheException', 'invalid_serializer is not a valid serializer engine for Memcached' - ); + $this->expectException('CacheException'); + $this->expectExceptionMessage('invalid_serializer is not a valid serializer engine for Memcached'); $Memcached->init($settings); } @@ -283,9 +282,8 @@ class MemcachedEngineTest extends CakeTestCase { 'serialize' => 'json' ); - $this->setExpectedException( - 'CacheException', 'Memcached extension is not compiled with json support' - ); + $this->expectException('CacheException'); + $this->expectExceptionMessage('Memcached extension is not compiled with json support'); $Memcached->init($settings); } @@ -308,9 +306,8 @@ class MemcachedEngineTest extends CakeTestCase { 'serialize' => 'msgpack' ); - $this->setExpectedException( - 'CacheException', 'msgpack is not a valid serializer engine for Memcached' - ); + $this->expectException('CacheException'); + $this->expectExceptionMessage('msgpack is not a valid serializer engine for Memcached'); $Memcached->init($settings); } @@ -333,9 +330,8 @@ class MemcachedEngineTest extends CakeTestCase { 'serialize' => 'igbinary' ); - $this->setExpectedException( - 'CacheException', 'Memcached extension is not compiled with igbinary support' - ); + $this->expectException('CacheException'); + $this->expectExceptionMessage('Memcached extension is not compiled with igbinary support'); $Memcached->init($settings); } @@ -356,7 +352,7 @@ class MemcachedEngineTest extends CakeTestCase { 'password' => 'password' ); - $this->setExpectedException('PHPUnit_Framework_Error_Warning'); + $this->expectWarning(); $Memcached->init($settings); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php index 3aa7b3383..8080a62c3 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php @@ -283,19 +283,15 @@ class PhpAclTest extends CakeTestCase { * @return void */ public function testInvalidConfigWithAroMissing() { - $this->setExpectedException( - 'AclException', - '"roles" section not found in configuration' - ); + $this->expectException('AclException'); + $this->expectExceptionMessage('"roles" section not found in configuration'); $config = array('aco' => array('allow' => array('foo' => ''))); $this->PhpAcl->build($config); } public function testInvalidConfigWithAcosMissing() { - $this->setExpectedException( - 'AclException', - 'Neither "allow" nor "deny" rules were provided in configuration.' - ); + $this->expectException('AclException'); + $this->expectExceptionMessage('Neither "allow" nor "deny" rules were provided in configuration.'); $config = array( 'roles' => array('Role/foo' => null), diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index da750cac6..6324d381f 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -2482,7 +2482,7 @@ XML; $this->assertEquals(array('Allow' => 'POST, DELETE'), $e->responseHeader()); } - $this->setExpectedException('MethodNotAllowedException'); + $this->expectException('MethodNotAllowedException'); $request->allowMethod('POST'); } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 5783f9a10..4661a358f 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -212,7 +212,7 @@ class CakeEmailTest extends CakeTestCase { $this->assertSame($expected, $this->CakeEmail->from()); $this->assertSame($this->CakeEmail, $result); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP', 'fail@cakephp.org' => 'From can only be one address')); } @@ -879,7 +879,7 @@ class CakeEmailTest extends CakeTestCase { ); $this->assertSame($expected, $this->CakeEmail->attachments()); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->attachments(array(array('nofile' => CAKE . 'basics.php', 'mimetype' => 'text/plain'))); } @@ -896,7 +896,7 @@ class CakeEmailTest extends CakeTestCase { $result = $this->CakeEmail->transportClass(); $this->assertInstanceOf('DebugTransport', $result); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->transport('Invalid'); $this->CakeEmail->transportClass(); } @@ -907,7 +907,7 @@ class CakeEmailTest extends CakeTestCase { * @return void */ public function testExtendTransport() { - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->transport('Extend'); $this->CakeEmail->transportClass(); } @@ -1068,7 +1068,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->config(array('empty')); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->send("Forgot to set From"); } @@ -1082,7 +1082,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->config(array('empty')); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->send("Forgot to set To"); } @@ -1724,7 +1724,7 @@ class CakeEmailTest extends CakeTestCase { $this->assertStringContainsString('Here is your value: 12345', $result['message']); $this->assertStringContainsString('This email was sent using the TestPlugin.', $result['message']); - $this->setExpectedException('MissingViewException'); + $this->expectException('MissingViewException'); $this->CakeEmail->template('test_plugin_tpl', 'plug_default')->send(); } @@ -2095,7 +2095,7 @@ class CakeEmailTest extends CakeTestCase { $result = $this->CakeEmail->emailFormat(); $this->assertEquals('html', $result); - $this->setExpectedException('SocketException'); + $this->expectException('SocketException'); $this->CakeEmail->emailFormat('invalid'); } diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 5a9605ce2..66aed5585 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -1842,9 +1842,11 @@ TEXT; protected function _checkException($message) { if (version_compare(PHP_VERSION, '7.4', '>=')) { - $this->setExpectedException('Error', $message); + $this->expectException(Error::class); + $this->expectExceptionMessage($message); } else { - $this->setExpectedException('PHPUnit_Framework_Error', $message); + $this->expectError(); + $this->expectErrorMessage($message); } } }