Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Nov 1, 2018
1 parent 6c1982e commit e8f7cba
Show file tree
Hide file tree
Showing 6 changed files with 627 additions and 308 deletions.
3 changes: 1 addition & 2 deletions Command/ScheduleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
use JMS\JobQueueBundle\Console\CronCommand;
use JMS\JobQueueBundle\Cron\CommandScheduler;
use JMS\JobQueueBundle\Cron\JobScheduler;
use JMS\JobQueueBundle\Cron\SchedulerRegistry;
use JMS\JobQueueBundle\Entity\CronJob;
use JMS\JobQueueBundle\Entity\Job;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -150,6 +148,7 @@ private function populateJobSchedulers()
{
$schedulers = [];
foreach ($this->schedulers as $scheduler) {
/** @var JobScheduler $scheduler */
foreach ($scheduler->getCommands() as $name) {
$schedulers[$name] = $scheduler;
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/CronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CronTest extends BaseTestCase
public function testSchedulesCommands()
{
$output = $this->doRun(array('--min-job-interval' => 1, '--max-runtime' => 12));
$this->assertEquals(2, substr_count($output, 'Scheduling command scheduled-every-few-seconds'));
$this->assertEquals(2, substr_count($output, 'Scheduling command scheduled-every-few-seconds'), $output);
}

protected function setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@

use JMS\JobQueueBundle\Console\CronCommand;
use JMS\JobQueueBundle\Entity\Job;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ScheduledEveryFewSecondsCommand extends ContainerAwareCommand implements CronCommand
class ScheduledEveryFewSecondsCommand extends Command implements CronCommand
{
public function shouldBeScheduled(\DateTime $lastRunAt)
protected static $defaultName = 'scheduled-every-few-seconds';

public function shouldBeScheduled(\DateTime $lastRunAt): bool
{
return time() - $lastRunAt->getTimestamp() >= 5;
}

public function createCronJob(\DateTime $_)
public function createCronJob(\DateTime $_): Job
{
return new Job('scheduled-every-few-seconds');
}

protected function configure()
{
$this->setName('scheduled-every-few-seconds');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Done');
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/config/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ framework:

services:
JMS\JobQueueBundle\Tests\Functional\TestBundle\Command\:
autoconfigure: true
autowire: true
resource: '../TestBundle/Command'
tags: ['console.command']
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
],
"require": {
"php": "^7.1",
"symfony/framework-bundle": "^4.0",
"symfony/debug": "^4.0",
"symfony/framework-bundle": "^3.4 || ^4.0",
"symfony/debug": "^3.4 || ^4.0",
"doctrine/common": "^2.3",
"symfony/process": "^4.0"
"symfony/process": "^3.4 || ^4.0"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "*",
Expand Down
Loading

0 comments on commit e8f7cba

Please # to comment.