Beispiel #1
0
 /**
  * @covers Pants\Target\Target::__construct
  * @covers Pants\Target\Target::execute
  */
 public function testDependIsExecuted()
 {
     $target = $this->getMockBuilder('\\Pants\\Target\\Target')->disableOriginalConstructor()->getMock();
     $target->expects($this->once())->method('execute')->will($this->returnSelf());
     $this->targets->expects($this->once())->method('__get')->with('test')->will($this->returnValue($target));
     $this->tasks->expects($this->once())->method('getIterator')->will($this->returnValue(new ArrayIterator()));
     $this->target->setDepends(array('test'))->execute();
 }
Beispiel #2
0
 /**
  * Add a target
  *
  * @param Target $target
  * @return Targets
  * @throws InvalidArgumentException
  */
 public function add(Target $target)
 {
     $name = $target->getName();
     if (isset($this->{$name})) {
         throw new InvalidArgumentException("A target already exists with the name of '{$name}'");
     }
     $this->targets[$name] = $target;
     return $this;
 }
Beispiel #3
0
 /**
  * Handle an XML target
  *
  * @return Target
  */
 public function handleTarget()
 {
     $target = new Target();
     $target->setName($this->xmlReader->getAttribute("name"));
     if ($this->xmlReader->isEmptyElement) {
         return $target;
     }
     while ($this->xmlReader->read()) {
         if ($this->xmlReader->name == "target" && $this->xmlReader->nodeType == XMLReader::END_ELEMENT) {
             return $target;
         } elseif ($this->xmlReader->nodeType == XMLReader::ELEMENT) {
             $target->getTasks()->add($this->handleTask());
         }
     }
 }