コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: TestCommands.php プロジェクト: jboysen/laravel-gcc
 public function testCleanCommand()
 {
     // mock the compiler
     \App::instance('gcc', Mockery::mock('GCCompiler')->shouldReceive('cleanup')->once()->mock());
     // start the actual test
     $testerClean = new Symfony\Component\Console\Tester\CommandTester(new Jboysen\LaravelGcc\Commands\Clean());
     $testerClean->execute(array());
     $output = $testerClean->getDisplay();
     $this->assertEquals("All compiled bundles are now removed.\n", $output);
 }
コード例 #3
0
 public function testExecute()
 {
     $conveyor = new \Webcreate\Conveyor\Conveyor();
     $application = new \Webcreate\Conveyor\Console\Application($conveyor);
     $application->add(new \Webcreate\Conveyor\Command\InitCommand());
     $conveyor->boot(new \Webcreate\Conveyor\IO\NullIO());
     $this->assertFileNotExists($this->tmpdir . '/conveyor.yml');
     $command = $application->find('init');
     $commandTester = new \Symfony\Component\Console\Tester\CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertFileExists($this->tmpdir . '/conveyor.yml');
 }
コード例 #4
0
 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'));
 }
コード例 #5
0
 /**
  * @test
  *
  * @throws \Codeception\Exception\ConfigurationException
  */
 public function hasInstalledVimConfigurationInTargetDirectory()
 {
     $target = Configuration::outputDir() . 'vimConfigTest';
     $this->cleanupFolder($target);
     Debug::debug('<info>Preparing command...</info>');
     $command = $this->getCommand();
     Debug::debug('<info>Preparing question helper...</info>');
     $this->mockQuestionHelper($command, function ($test, $order, ConfirmationQuestion $question) {
         // Pick the first choice
         if ($order == 0) {
             return true;
         }
         throw new UnhandledQuestionException();
     });
     Debug::debug('<info>Executing...</info>');
     $tester = new \Symfony\Component\Console\Tester\CommandTester($command);
     $tester->execute([VimConfigurationInstallCommand::TARGET_DIR_ARGUMENT => $target]);
     $output = $tester->getDisplay();
     Debug::debug($output);
     $finder = new Finder();
     $count = $finder->directories()->ignoreDotFiles(false)->in($target)->count();
     $this->assertNotEquals(0, $count, 'No files have been copied!');
 }
コード例 #6
0
 /**
  * @test
  *
  * @covers  ::execute
  * @covers  ::configure
  * @covers  ::findTemplates
  * @covers  ::getTemplatesList
  * @covers  ::formatTemplatesList
  * @covers  ::createTemplate
  */
 public function hasCopiedFilesIntoTargetLocation()
 {
     $target = Configuration::outputDir() . 'tmp';
     // Eventual pre-cleanup
     $this->cleanupFolder($target);
     Debug::debug('<info>Preparing command...</info>');
     $command = $this->getCommand();
     Debug::debug('<info>Preparing question helper...</info>');
     $this->mockQuestionHelper($command, function ($test, $order, Question $question) {
         // Pick the first choice
         if ($order == 0) {
             return true;
         }
         throw new UnhandledQuestionException();
     });
     Debug::debug('<info>Executing...</info>');
     $tester = new \Symfony\Component\Console\Tester\CommandTester($command);
     $tester->execute([TemplateCommand::ARGUMENT_PATH_NAME => $target]);
     $output = $tester->getDisplay();
     Debug::debug($output);
     $finder = new Finder();
     $count = $finder->directories()->in($target)->count();
     $this->assertNotEquals(0, $count, 'No files have been copied!');
 }