예제 #1
0
 function it_skips_duplicated_tasks(Task $task1, Task $task2, Task $task3)
 {
     $task1->getDependencies()->willReturn(array('minify', 'build'));
     $task2->getDependencies()->willReturn(array('minify'));
     $stack = new TaskStack();
     $stack->push($task3->getWrappedObject());
     $stack->push($task2->getWrappedObject());
     $stack->push($task1->getWrappedObject());
     $this->getStackForTask('publish')->shouldBeLike($stack);
 }
예제 #2
0
파일: FredSpec.php 프로젝트: wouterj/fred
 function it_accepts_nested_tasks(TaskStack $stack)
 {
     $stack->push(Argument::that(function ($task) {
         return $task->getName() === 'build' && $task->getDependencies() === array('test', 'minify', 'cleanup');
     }));
     $this->task('build', array('test', 'minify', 'cleanup'));
 }
예제 #3
0
파일: Fred.php 프로젝트: wouterj/fred
 public function task($name, $dependencies = null, $closure = null)
 {
     if (null === $closure) {
         if (is_callable($dependencies)) {
             // ->task('default', function () { ... });
             $closure = $dependencies;
             $dependencies = array();
         } elseif (is_array($dependencies)) {
             // ->task('default', ['minify', 'build'])
             $closure = function () {
             };
         }
     } elseif (is_array($dependencies) && is_callable($closure)) {
         // ->task('default', ['minify'], function () { ... });
         // do nothing, it's valid now
     } else {
         throw new \InvalidArgumentException(sprintf("Invalid argument given to Chef#task(). It accepts one of:\n%s", implode("* \n", array('task(string name, callable task)', 'task(string name, array taskNames)', 'task(string name, array dependencies, callable task)'))));
     }
     $this->taskStack->push(new Task($name, (array) $dependencies, $closure));
 }
예제 #4
0
파일: TaskStack.php 프로젝트: wouterj/fred
 /**
  * @return TaskStack
  */
 public function getStackForTask($name)
 {
     if (!$this->has($name)) {
         throw new TaskNotFoundException($name);
     }
     $stack = new TaskStack();
     $task = $this->tasks[$name];
     foreach ($task->getDependencies() as $dep) {
         $stack->merge($this->getStackForTask($dep), true);
     }
     $stack->push($task);
     return $stack;
 }