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);
 }
Example #2
0
<?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);
Example #3
0
<?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);
Example #4
0
 public function testWhenFailOnErrorFalseAndExitCodeNotEqualZeroRunIsSuccessful()
 {
     $task = new ExitCodeOneStub();
     $task->setFailOnError(false);
     $collection = new Collection();
     $collection->addTask($task);
     $this->runner->setTaskCollection($collection);
     $this->runner->run($this->payload);
 }
Example #5
0
<?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);
Example #6
0
<?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);
Example #7
0
<?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);