function it_should_run_a_task_on_demand(Project $project, HelperSet $helperSet, Command $command, InputInterface $input, Output $output) { $project->get('test')->willReturn($command); $this->setIO($input, $output); $project->getHelperSet()->willReturn($helperSet); $this->setApplication($project); $project->runTask('test', $input, $output)->shouldBeCalled(); $this->runTask('test', $output, $input); }
function it_should_run_commands(Project $project, Command $foo, Command $bar, InputInterface $input, OutputInterface $output) { $foo->getName()->willReturn('foo'); $bar->getName()->willReturn('bar'); $project->resolveDependencies(Argument::any())->willReturn([]); $project->get('foo')->willReturn($foo); $project->get('bar')->willReturn($bar); $this->beConstructedWith('test', $project, ['foo', 'bar']); $foo->run($input, $output)->shouldBeCalled(); $bar->run($input, $output)->shouldBeCalled(); $this->execute($input, $output); }
<?php require 'vendor/autoload.php'; date_default_timezone_set('Europe/Amsterdam'); # Include the task/task library and your dependencies. use PhotoOrganize\Application\DefaultModule; use PhotoOrganize\Application\SymlinkUseCase; use Ray\Di\Injector; use Rx\Observable; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Task\Project; $defaultModule = new DefaultModule(); $injector = new Injector($defaultModule); $project = new Project('photo_organize'); /** * @param OutputInterface $output * @return \Rx\Observer\CallbackObserver */ function outputObserver(OutputInterface $output) { return new Rx\Observer\CallbackObserver(function ($value) use($output) { $time = date("Y-m-d H:i:s"); $output->writeln("{$time} | {$value}"); }, function (Exception $error) use($output) { $output->writeln(date("Y-m-d H:i:s") . " | Exception: " . $error->getMessage()); }, function () use($output) { $output->writeln(date("Y-m-d H:i:s") . " | Complete!"); }); } $project->addTask('symlink', function () use($injector) {