/** * @covers Pants\Project::execute */ public function testBaseDirChangesTheCurrentWorkingDirectory() { $task = $this->getMock('\\Pants\\Task\\Task'); $task->expects($this->once())->method('execute')->will($this->returnSelf()); $this->project->getTasks()->expects($this->once())->method('getIterator')->will($this->returnValue(new ArrayIterator(array($task)))); $cwd = getcwd(); $this->project->setBaseDirectory('/')->execute(); $this->assertEquals('/', getcwd()); chdir($cwd); }
/** * Handle the XML project * * @return Project */ public function handleProject() { $project = new Project(); $project->setDefault($this->xmlReader->getAttribute("default")); while ($this->xmlReader->read()) { if ($this->xmlReader->name == "project" && $this->xmlReader->nodeType == XMLReader::END_ELEMENT) { return $project; } elseif ($this->xmlReader->name == "target" && $this->xmlReader->nodeType == XMLReader::ELEMENT) { $project->getTargets()->add($this->handleTarget()); } elseif ($this->xmlReader->nodeType == XMLReader::ELEMENT) { $project->getTasks()->add($this->handleTask()); } } }