mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 05:32:20 +00:00
use a mock to test correct redis exceptions are surfaced
This commit is contained in:
parent
599dc4c8be
commit
8113e624c4
3 changed files with 24 additions and 4 deletions
|
@ -13,8 +13,16 @@ class Resque_Tests_RedisTest extends Resque_Tests_TestCase
|
|||
*/
|
||||
public function testRedisExceptionsAreSurfaced()
|
||||
{
|
||||
$redis = new Resque_Redis('redis://255.255.255.255:1234');
|
||||
$redis->ping();
|
||||
$mockCredis = $this->getMockBuilder('Credis_Client')
|
||||
->setMethods(['connect', '__call'])
|
||||
->getMock();
|
||||
$mockCredis->expects($this->any())->method('__call')
|
||||
->will($this->throwException(new CredisException('failure')));
|
||||
|
||||
Resque::setBackend(function($database) use ($mockCredis) {
|
||||
return new Resque_Redis('localhost:6379', $database, $mockCredis);
|
||||
});
|
||||
Resque::redis()->ping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue