mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
2.0.0 Add namespacing + PHP8.0 support (#1)
2.0.0 (2021-02-19) Moved to PSR-4 Namespaced codebase Added more comments throughout Co-Authored-By: idanoo <daniel@m2.nz> Co-Committed-By: idanoo <daniel@m2.nz>
This commit is contained in:
parent
ebec2f7bf7
commit
80d64e79ff
56 changed files with 2215 additions and 1423 deletions
95
tests/bootstrap.php
Normal file
95
tests/bootstrap.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Resque\Test;
|
||||
|
||||
/**
|
||||
* Resque test bootstrap file - sets up a test environment.
|
||||
*
|
||||
* @package Resque/Tests
|
||||
* @author Daniel Mason <daniel@m2.nz>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
$loader = require __DIR__ . '/../vendor/autoload.php';
|
||||
// $loader->add('Resque_Tests', __DIR__);
|
||||
|
||||
# Redis configuration
|
||||
global $redisTestServer;
|
||||
$redisTestServer = getenv("REDIS_SERVER") ?: "redis";
|
||||
\Resque\Resque::setBackend($redisTestServer);
|
||||
|
||||
# Check Redis is accessable locally
|
||||
try {
|
||||
$redisTest = new \Resque\Redis($redisTestServer);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Unable to connect to redis. Please check there is a redis-server running.");
|
||||
}
|
||||
$redisTest = null;
|
||||
|
||||
# Cleanup forked workers cleanly
|
||||
if (function_exists('pcntl_signal')) {
|
||||
pcntl_signal(SIGINT, function() { exit; });
|
||||
pcntl_signal(SIGTERM, function() { exit; });
|
||||
}
|
||||
|
||||
# Bootstrap it
|
||||
class TestJob
|
||||
{
|
||||
public static $called = false;
|
||||
|
||||
public function perform()
|
||||
{
|
||||
self::$called = true;
|
||||
}
|
||||
}
|
||||
|
||||
class FailingJobException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class FailingJob
|
||||
{
|
||||
public function perform()
|
||||
{
|
||||
throw new FailingJobException('Message!');
|
||||
}
|
||||
}
|
||||
|
||||
class TestJobWithoutPerformMethod
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class TestJobWithSetUp
|
||||
{
|
||||
public static $called = false;
|
||||
public $args = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
self::$called = true;
|
||||
}
|
||||
|
||||
public function perform()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestJobWithTearDown
|
||||
{
|
||||
public static $called = false;
|
||||
public $args = false;
|
||||
|
||||
public function perform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
self::$called = true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue