Update for PHP7.4 compatibility + UnitTests

This commit is contained in:
Daniel Mason 2020-04-11 09:24:18 +12:00
parent 493c12846a
commit b99217f2c0
9 changed files with 51 additions and 75 deletions

View file

@ -13,7 +13,7 @@ class Resque_Tests_EventTest extends Resque_Tests_TestCase
private $callbacksHit = [];
private $worker;
public function setUp()
public function setUp(): void
{
Test_Job::$called = false;
@ -23,7 +23,7 @@ class Resque_Tests_EventTest extends Resque_Tests_TestCase
$this->worker->registerWorker();
}
public function tearDown()
public function tearDown(): void
{
Resque_Event::clearListeners();
$this->callbacksHit = [];

View file

@ -15,7 +15,7 @@ class Resque_Tests_JobStatusTest extends Resque_Tests_TestCase
*/
protected $worker;
public function setUp()
public function setUp(): void
{
parent::setUp();

View file

@ -12,7 +12,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
{
protected $worker;
public function setUp()
public function setUp(): void
{
parent::setUp();
@ -44,7 +44,9 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
*/
public function testObjectArgumentsCannotBePassedToJob()
{
$args = new stdClass;
$this->expectException(InvalidArgumentException::class);
$args = new stdClass();
$args->test = 'somevalue';
Resque::enqueue('jobs', 'Test_Job', $args);
}
@ -121,6 +123,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
*/
public function testJobWithoutPerformMethodThrowsException()
{
$this->expectException(Resque_Exception::class);
Resque::enqueue('jobs', 'Test_Job_Without_Perform_Method');
$job = $this->worker->reserve();
$job->worker = $this->worker;
@ -132,6 +135,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
*/
public function testInvalidJobThrowsException()
{
$this->expectException(Resque_Exception::class);
Resque::enqueue('jobs', 'Invalid_Job');
$job = $this->worker->reserve();
$job->worker = $this->worker;
@ -334,7 +338,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
$this->assertEquals($removedItems, 2);
$this->assertEquals(Resque::size($queue), 1);
$item = Resque::pop($queue);
$this->assertInternalType('array', $item['args']);
$this->assertIsArray($item['args']);
$this->assertEquals(10, $item['args'][0]['bar'], 'Wrong items were dequeued from queue!');
}

View file

@ -181,12 +181,14 @@ class Resque_Tests_RedisTest extends Resque_Tests_TestCase
/**
* @dataProvider bogusDsnStringProvider
*
* @expectedException InvalidArgumentException
*
* @param $dsn
*/
public function testParsingBogusDsnStringThrowsException($dsn)
{
// The next line should throw an InvalidArgumentException
$this->expectException(InvalidArgumentException::class);
Resque_Redis::parseDsn($dsn);
}
}

View file

@ -13,12 +13,12 @@ class Resque_Tests_TestCase extends PHPUnit\Framework\TestCase
protected $resque;
protected $redis;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
date_default_timezone_set('UTC');
}
public function setUp()
public function setUp(): void
{
// Setup redis connection for testing.
global $redisTestServer;