diff --git a/.circleci/config.yml b/.circleci/config.yml index 557c1a9a..cac5ed72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,8 +16,11 @@ jobs: steps: - checkout - run: composer install - - run: ./vendor/bin/phpunit test/unit - - run: ./vendor/bin/phpunit test/performance + - run: composer test -- --log-junit test-results/junit.xml + - store_test_results: + path: test-results/junit.xml + - store_artifacts: + path: test-results/junit.xml workflows: build_and_test: diff --git a/.gitignore b/.gitignore index a3d2da46..2a6f27f4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ tags atlassian-ide-plugin.xml composer.lock +test-results test/performance/rest-interface/.vagrant/ test/performance/rest-interface/config/tripod-config-*.json diff --git a/README.md b/README.md index e39c9b61..0cc7514a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ Quickstart ```php require_once("tripod.inc.php"); +// Queue worker must register these event listeners +Resque_Event::listen('beforePerform', [\Tripod\Mongo\Jobs\JobBase::class, 'beforePerform']); +Resque_Event::listen('onFailure', [\Tripod\Mongo\Jobs\JobBase::class, 'onFailure']); + \Tripod\Config::setConfig($conf); // set the config, usually read in as JSON from a file $tripod = new Driver( @@ -79,9 +83,9 @@ $tripod->saveChanges( Requirements ---- -PHP >= 5.4.x +PHP >= 5.5 -Mongo 2.6.x and up. +Mongo 3.2.x and up. MongoDB PHP driver version. http://mongodb.github.io/mongo-php-driver/#installation diff --git a/composer.json b/composer.json index 9a9d929f..203c5a7b 100644 --- a/composer.json +++ b/composer.json @@ -34,5 +34,8 @@ }, "autoload": { "classmap": ["src/"] + }, + "scripts": { + "test": "phpunit" } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..83a2fac8 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,15 @@ + + + + + + + + + test/performance + + + test/unit + + + diff --git a/src/mongo/base/JobBase.class.php b/src/mongo/base/JobBase.class.php index 93d052fc..0a8888fa 100644 --- a/src/mongo/base/JobBase.class.php +++ b/src/mongo/base/JobBase.class.php @@ -15,6 +15,24 @@ */ abstract class JobBase extends \Tripod\Mongo\DriverBase { + /** + * Resque Job arguments, set by Resque_Job_Factory + * @var array + */ + public $args; + + /** + * Resque Job queue, set by Resque_Job_Factory + * @var string + */ + public $queue; + + /** + * Resque Job + * @var \Resque_Job + */ + public $job; + private $tripod; const TRIPOD_CONFIG_KEY = 'tripodConfig'; const TRIPOD_CONFIG_GENERATOR = 'tripodConfigGenerator'; @@ -29,12 +47,6 @@ abstract class JobBase extends \Tripod\Mongo\DriverBase /** @var \Tripod\Timer */ protected $timer; - public function __construct() - { - \Resque_Event::listen('beforePerform', [self::class, 'beforePerform']); - \Resque_Event::listen('onFailure', [self::class, 'onFailure']); - } - /** * The main method of the job * diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 00000000..83257fca --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,7 @@ + - - - . - - - \ No newline at end of file diff --git a/test/unit/mongo/MongoTripodConfigTest.php b/test/unit/mongo/MongoTripodConfigUnitTest.php similarity index 99% rename from test/unit/mongo/MongoTripodConfigTest.php rename to test/unit/mongo/MongoTripodConfigUnitTest.php index f6412eb9..7dd5612e 100644 --- a/test/unit/mongo/MongoTripodConfigTest.php +++ b/test/unit/mongo/MongoTripodConfigUnitTest.php @@ -6,7 +6,7 @@ use \MongoDB\Client; use \MongoDB\Driver\Exception\ConnectionTimeoutException; -class MongoTripodConfigTest extends MongoTripodTestBase +class MongoTripodConfigUnitTest extends MongoTripodTestBase { /** * @var \Tripod\Mongo\Config diff --git a/test/unit/phpunit.xml b/test/unit/phpunit.xml deleted file mode 100644 index 162f96d9..00000000 --- a/test/unit/phpunit.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - ../../src - - - ../../lib - - - - - - . - - - \ No newline at end of file