<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Example\TaskFail; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; use AndreasWeber\Runner\Task\Retries\Retries; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new Task2()); $retryTask = new TaskFail(2); // task will fail 2 times, just for demonstration ;-) $retryTask->setMaxRetries(new Retries(3)); // task will get retried 3 times $collection->addTask($retryTask); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->run($payload); // dump payload var_export($payload);
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new Task2()); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->run($payload); // dump payload var_export($payload);
public function testTaskUnlessCallbackIsInvoked() { $mock = $this->getMock('AndreasWeber\\Runner\\Test\\Stub\\TaskInvokedStub'); $mock->expects($this->once())->method('trigger')->willReturn(null); $task = new UnlessFalseTaskStub(); $collection = new Collection(); $collection->addTask($task); $this->runner->setTaskCollection($collection); $this->runner->on('runner.task.unless', array($mock, 'trigger')); $this->runner->run($this->payload); }
public function testWhenFailOnErrorFalseAndExitCodeNotEqualZeroRunIsSuccessful() { $task = new ExitCodeOneStub(); $task->setFailOnError(false); $collection = new Collection(); $collection->addTask($task); $this->runner->setTaskCollection($collection); $this->runner->run($this->payload); }
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Example\TaskUnless; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new TaskUnless()); // task won't run before 21:00, see unless() $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->run($payload); // dump payload var_export($payload);
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Example\TaskExitCode; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new Task2()); // trigger an exception, when exit code is not equal zero or null $taskExitCode = new TaskExitCode(); $taskExitCode->setFailOnError(true); $collection->addTask($taskExitCode); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); // we're awaiting an exception $runner->run($payload);
public function testAddTasksByConstructor() { $collection = new Collection(array($this->task)); $this->assertCount(1, $collection->getTasks()); }
<?php /* * This file is part of the andreas-weber/php-runner library. * * (c) Andreas Weber <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use AndreasWeber\Runner\Example\Task1; use AndreasWeber\Runner\Example\Task2; use AndreasWeber\Runner\Example\TaskSetUp; use AndreasWeber\Runner\Example\TaskUnless; use AndreasWeber\Runner\Payload\ArrayPayload; use AndreasWeber\Runner\Runner; use AndreasWeber\Runner\Task\Collection; require_once __DIR__ . '/../resources/bootstrap.php'; $collection = new Collection(); $collection->addTask(new Task1()); $collection->addTask(new TaskSetUp()); $payload = new ArrayPayload(); $runner = new Runner($collection, $logger); $runner->run($payload); // dump payload var_export($payload);