public function testRefreshJobs()
 {
     $cli = new \Symfony\Component\Console\Application();
     $cli->addCommands(array(new \ebussola\job\console\RefreshJobsCommand(), new \ebussola\job\console\ListJobsCommand()));
     $refresh_tester = new \Symfony\Component\Console\Tester\CommandTester($cli->find('jobschedule:refresh'));
     $list_tester = new \Symfony\Component\Console\Tester\CommandTester($cli->find('jobschedule:list'));
     // stage 1
     $refresh_tester->execute(array('command' => 'jobschedule:refresh'));
     $output = $refresh_tester->getDisplay();
     $this->assertContains('Jobs Reloaded', $output);
     $list_tester->execute(array('command' => 'jobschedule:list'));
     $output = $list_tester->getDisplay();
     $this->assertContains('[1]', $output);
     $this->assertContains('[2]', $output);
     $this->assertContains('[3]', $output);
     $this->assertContains('[4]', $output);
     $this->assertContains('[5]', $output);
     $this->assertContains('[6]', $output);
     // stage 2
     $refresh_tester->execute(array('command' => 'jobschedule:refresh'));
     $output = $refresh_tester->getDisplay();
     $this->assertContains('Jobs Reloaded', $output);
     $list_tester->execute(array('command' => 'jobschedule:list'));
     $output = $list_tester->getDisplay();
     $this->assertNotContains('[1]', $output);
     $this->assertNotContains('[2]', $output);
     $this->assertContains('[3]', $output);
     $this->assertContains('[4]', $output);
     $this->assertContains('[5]', $output);
     $this->assertContains('[6]', $output);
 }
 public function testRunWithoutProblems()
 {
     $input = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface');
     $output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $output->expects($this->any())->method('getFormatter')->will($this->returnValue($this->getMock('Symfony\\Component\\Console\\Formatter\\OutputFormatterInterface')));
     $command = new TaskList();
     $command->setContainer(self::$DI['cli']);
     $application = new \Symfony\Component\Console\Application();
     $application->add($command);
     $setupCommand = $application->find('task-manager:task:list');
     $setupCommand->execute($input, $output);
 }
 public function setUp()
 {
     $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'user' => 'root', 'password' => '', 'memory' => true));
     $this->data = new \ebussola\job\jobdata\Doctrine($conn, $this->table_name);
     $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($conn)));
     $cli = new \Symfony\Component\Console\Application();
     $cli->setHelperSet($helperSet);
     $cli->addCommands(array(new \ebussola\job\console\InitCommand()));
     $cmd_tester = new \Symfony\Component\Console\Tester\CommandTester($cli->find('jobschedule:init'));
     $cmd_tester->execute(array('command' => 'jobschedule:init', 'table_name' => $this->table_name));
     //Insert some data
     $conn->insert($this->table_name, array('id' => 1, 'expires_on' => strtotime('+1 hour'), 'runner_class' => 'ebussola\\job\\runner', 'schedule' => '@daily', 'command' => 'foo'));
     $conn->insert($this->table_name, array('id' => 2, 'expires_on' => strtotime('+1 hour'), 'runner_class' => 'ebussola\\job\\runner', 'schedule' => '@daily', 'command' => 'bar'));
 }