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 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); }
/** * @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!'); }
/** * @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!'); }