addChild() public method

public addChild ( mageekguy\atoum\template\data $child )
$child mageekguy\atoum\template\data
Ejemplo n.º 1
0
 public function testCurrent()
 {
     $iterator = new template\iterator();
     $this->assert->boolean($iterator->valid())->isFalse()->variable($iterator->current())->isNull();
     $template = new atoum\template();
     $template->addChild($tag = new template\tag(uniqid()));
     $iterator->addTag($tag->getTag(), $template);
     $this->assert->boolean($iterator->valid())->isTrue()->object($iterator->current())->isIdenticalTo($tag);
     $iterator->next();
     $this->assert->boolean($iterator->valid())->isFalse()->variable($iterator->current())->isNull();
 }
Ejemplo n.º 2
0
 public function testAddChild()
 {
     $this->if($this->newTestedInstance)->then->boolean($this->testedInstance->hasChildren())->isFalse()->object($this->testedInstance->addChild($childTemplate = new atoum\template()))->isTestedInstance->object($childTemplate->getParent())->isTestedInstance->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))->object($this->testedInstance->addChild($childTemplate))->isTestedInstance->object($childTemplate->getParent())->isTestedInstance->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))->if($otherTemplate = new atoum\template(), $otherTemplate->addChild($otherChildTemplate = new atoum\template()))->then->array($otherTemplate->getChildren())->isIdenticalTo(array($otherChildTemplate))->object($otherChildTemplate->getParent())->isIdenticalTo($otherTemplate)->object($this->testedInstance->addChild($otherChildTemplate))->isTestedInstance->array($otherTemplate->getChildren())->isEmpty()->object($otherChildTemplate->getParent())->isTestedInstance->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))->if($this->newTestedInstance, $templateWithId = new atoum\template\tag(uniqid()), $templateWithId->setId($id = uniqid()), $templateWithSameId = clone $templateWithId)->then->boolean($this->testedInstance->hasChildren())->isFalse()->object($this->testedInstance->addChild($templateWithId))->isTestedInstance->array($this->testedInstance->getChildren())->isIdenticalTo(array($templateWithId))->object($this->testedInstance->addChild($templateWithId))->isTestedInstance->array($this->testedInstance->getChildren())->isIdenticalTo(array($templateWithId))->exception(function ($test) use($templateWithSameId) {
         $test->testedInstance->addChild($templateWithSameId);
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Id \'' . $id . '\' is already defined');
 }
Ejemplo n.º 3
0
 public function testGetChild()
 {
     $template = new atoum\template();
     $this->assert->variable($template->getChild(0))->isNull()->variable($template->getChild(rand(1, PHP_INT_MAX)))->isNull()->variable($template->getChild(-rand(1, PHP_INT_MAX)))->isNull();
     $template->addChild($childTemplate = new atoum\template());
     $this->assert->variable($template->getChild(0))->isIdenticalTo($childTemplate)->variable($template->getChild(rand(1, PHP_INT_MAX)))->isNull()->variable($template->getChild(-rand(1, PHP_INT_MAX)))->isNull();
 }
Ejemplo n.º 4
0
 public function setParent(atoum\template $parent)
 {
     $parent->addChild($this);
     return $this;
 }