mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
test: Replace deprecated setExpectedException()
This commit is contained in:
parent
b1417587ad
commit
75437a4a85
5 changed files with 26 additions and 32 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -2482,7 +2482,7 @@ XML;
|
|||
$this->assertEquals(array('Allow' => 'POST, DELETE'), $e->responseHeader());
|
||||
}
|
||||
|
||||
$this->setExpectedException('MethodNotAllowedException');
|
||||
$this->expectException('MethodNotAllowedException');
|
||||
$request->allowMethod('POST');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue