Skip to content

Improved Tests with unit and functional tests #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
tools:
external_code_coverage:
timeout: 300
runs: 6
timeout: 1200
40 changes: 29 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm

env:
- STORAGE=array
- STORAGE=doctrine
matrix:
fast_finish: true
include:
- php: 5.6
env:
- STORAGE=doctrine
- CODE_COVERAGE=true
- php: 5.6
env:
- STORAGE=array
- php: 7.0
env:
- STORAGE=doctrine
- php: 7.0
env:
- STORAGE=array
- php: hhvm
env:
- STORAGE=doctrine
- php: hhvm
env:
- STORAGE=array

install:
- composer self-update
- composer update
- wget https://scrutinizer-ci.com/ocular.phar

before_script:
- STORAGE=doctrine tests/app/console doctrine:database:create
Expand All @@ -23,4 +35,10 @@ script:
- phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover

after_script:
- php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover
- if [[ $CODE_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
- if [[ $CODE_COVERAGE == 'true' ]]; then php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover ; fi

cache:
directories:
- "$HOME/.composer/cache"
- vendor
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "~5.5 || ~7.0",
"php": "~5.6 || ~7.0",
"php-task/php-task": "dev-master",
"symfony/http-kernel": "^2.6",
"symfony/dependency-injection": "^2.6",
Expand All @@ -22,13 +22,19 @@
"phpunit/phpunit": "^4.8",
"symfony/framework-bundle": "^2.6",
"symfony/finder": "^2.6",
"doctrine/doctrine-bundle": "^1.5"
"doctrine/doctrine-bundle": "^1.5",
"doctrine/data-fixtures": "^1.2"
},
"autoload": {
"psr-4": {
"Task\\TaskBundle\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Task\\TaskBundle\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
Expand Down
18 changes: 10 additions & 8 deletions src/Command/DebugTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Task\Execution\TaskExecutionRepositoryInterface;
use Task\Storage\TaskExecutionRepositoryInterface;

/**
* Run pending tasks.
Expand All @@ -26,17 +26,17 @@ class DebugTasksCommand extends Command
/**
* @var TaskExecutionRepositoryInterface
*/
private $storage;
private $taskExecutionRepository;

/**
* @param string $name
* @param TaskExecutionRepositoryInterface $storage
* @param TaskExecutionRepositoryInterface $taskExecutionRepository
*/
public function __construct($name, TaskExecutionRepositoryInterface $storage)
public function __construct($name, TaskExecutionRepositoryInterface $taskExecutionRepository)
{
parent::__construct($name);

$this->storage = $storage;
$this->taskExecutionRepository = $taskExecutionRepository;
}

/**
Expand All @@ -45,17 +45,19 @@ public function __construct($name, TaskExecutionRepositoryInterface $storage)
protected function configure()
{
$this->setDescription('Debug tasks')
->addOption('limit', 'l', InputOption::VALUE_REQUIRED, '', null);
->addOption('page', 'p', InputOption::VALUE_REQUIRED, '', 1)
->addOption('page-size', null, InputOption::VALUE_REQUIRED, '', null);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$limit = $input->getOption('limit');
$page = $input->getOption('page');
$pageSize = $input->getOption('page-size');

$executions = $this->storage->findAll($limit);
$executions = $this->taskExecutionRepository->findAll($page, $pageSize);

$table = new Table($output);
$table->setHeaders(['uuid', 'status', 'handler', 'schedule time', 'end time', 'duration']);
Expand Down
8 changes: 4 additions & 4 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Task\Runner\TaskRunnerInterface;
use Task\Scheduler\SchedulerInterface;
use Task\Scheduler\TaskSchedulerInterface;

/**
* Run pending tasks.
Expand All @@ -28,16 +28,16 @@ class RunCommand extends Command
private $runner;

/**
* @var SchedulerInterface
* @var TaskSchedulerInterface
*/
private $scheduler;

/**
* @param string $name
* @param TaskRunnerInterface $runner
* @param SchedulerInterface $scheduler
* @param TaskSchedulerInterface $scheduler
*/
public function __construct($name, TaskRunnerInterface $runner, SchedulerInterface $scheduler)
public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInterface $scheduler)
{
parent::__construct($name);

Expand Down
22 changes: 14 additions & 8 deletions src/Command/ScheduleTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Task\Scheduler\SchedulerInterface;
use Task\Scheduler\TaskSchedulerInterface;

/**
* Schedule task.
*/
class ScheduleTaskCommand extends Command
{
/**
* @var SchedulerInterface
* @var TaskSchedulerInterface
*/
private $scheduler;

/**
* @param string $name
* @param SchedulerInterface $runner
* @param TaskSchedulerInterface $runner
*/
public function __construct($name, SchedulerInterface $runner)
public function __construct($name, TaskSchedulerInterface $runner)
{
parent::__construct($name);

Expand All @@ -46,9 +46,10 @@ protected function configure()
{
$this
->setDescription('Run pending tasks')
->addArgument('handler', InputArgument::REQUIRED)
->addArgument('handlerClass', InputArgument::REQUIRED)
->addArgument('workload', InputArgument::OPTIONAL)
->addOption('cron-expression', 'c', InputOption::VALUE_REQUIRED)
->addOption('execution-date', null, InputOption::VALUE_REQUIRED)
->addOption('end-date', null, InputOption::VALUE_REQUIRED);
}

Expand All @@ -57,16 +58,17 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$handler = $input->getArgument('handler');
$handlerClass = $input->getArgument('handlerClass');
$workload = $input->getArgument('workload');
$cronExpression = $input->getOption('cron-expression');
$executionDateString = $input->getOption('execution-date');
$endDateString = $input->getOption('end-date');

if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln(sprintf('Schedule task "%s" with workload "%s"', $handler, $workload));
$output->writeln(sprintf('Schedule task "%s" with workload "%s"', $handlerClass, $workload));
}

$taskBuilder = $this->scheduler->createTask($input->getArgument('handler'), $input->getArgument('workload'));
$taskBuilder = $this->scheduler->createTask($handlerClass, $workload);

if ($cronExpression !== null) {
$endDate = null;
Expand All @@ -77,6 +79,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$taskBuilder->cron($cronExpression, new \DateTime(), $endDate);
}

if ($executionDateString !== null) {
$taskBuilder->executeAt(new \DateTime($executionDateString));
}

$this->scheduler->addTask($taskBuilder->getTask());
}
}
94 changes: 0 additions & 94 deletions src/DoctrineStorage/TaskExecutionRepository.php

This file was deleted.

Loading