mageekguy\atoum\template::addChild PHP Method

addChild() public method

public addChild ( mageekguy\atoum\template\data $child )
$child mageekguy\atoum\template\data
    public function addChild(template\data $child)
    {
        if ($this->isChild($child) === false) {
            $id = $child->getId();
            if ($id !== null && $this->idExists($id) === true) {
                throw new exceptions\runtime('Id \'' . $id . '\' is already defined');
            }
            if ($child->parentIsSet() === true) {
                $child->unsetParent();
            }
            $child->rank = sizeof($this->children);
            $this->children[$child->rank] = $child;
            $child->parent = $this;
        }
        return $this;
    }

Usage Example

Example #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();
 }
All Usage Examples Of mageekguy\atoum\template::addChild