示例#1
0
文件: tag.php 项目: xihewang/atoum
 public function testSetId()
 {
     $this->if($template = new template\tag(uniqid()))->then->exception(function () use($template) {
         $template->setId('');
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Id must not be empty')->object($template->setId($id = uniqid()))->isIdenticalTo($template)->string($template->getId())->isEqualTo($id)->object($template->setId($id = uniqid()))->isIdenticalTo($template)->string($template->getId())->isEqualTo($id)->if($root = new template\tag(uniqid()))->and($root->setId($id = uniqid()))->and($root->addChild($template = new template\tag(uniqid())))->then->exception(function () use($template, $id) {
         $template->setId($id);
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Id \'' . $id . '\' is already defined in line unknown at offset unknown');
 }
示例#2
0
 public function testAddTemplate()
 {
     $iterator = new template\iterator();
     $template = new atoum\template();
     $this->assert->object($iterator->addTag(uniqid(), $template))->isIdenticalTo($iterator)->sizeOf($iterator)->isZero();
     $template->addChild($tag = new template\tag(uniqid()));
     $this->assert->object($iterator->addTag(uniqid(), $template))->isIdenticalTo($iterator)->sizeOf($iterator)->isZero()->object($iterator->addTag($tag->getTag(), $template))->isIdenticalTo($iterator)->sizeOf($iterator)->isEqualTo(1);
     $tag->addChild($childTag = new template\tag($tag->getTag()));
     $iterator = new template\iterator();
     $this->assert->object($iterator->addTag(uniqid(), $template))->isIdenticalTo($iterator)->sizeOf($iterator)->isZero()->object($iterator->addTag($tag->getTag(), $template))->isIdenticalTo($iterator)->sizeOf($iterator)->isEqualTo(2);
 }
示例#3
0
 public function test__unset()
 {
     $template = new atoum\template();
     $template->addChild($childTag = new atoum\template\tag(uniqid()));
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty();
     unset($template->{$childTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty();
     $template->{$childTag->getTag()} = uniqid();
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isNotEmpty();
     unset($template->{$childTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty();
     $template->addChild($otherChildTag = new atoum\template\tag(uniqid()));
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty();
     unset($template->{$childTag->getTag()});
     unset($template->{$otherChildTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty();
     $template->{$childTag->getTag()} = uniqid();
     $template->{$otherChildTag->getTag()} = uniqid();
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isNotEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isNotEmpty();
     unset($template->{$childTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isNotEmpty();
     unset($template->{$otherChildTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty();
     $childTag->addChild($littleChildTag = new atoum\template\tag(uniqid()));
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty()->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()->string($littleChildTag->getData())->isEmpty();
     $template->{$childTag->getTag()} = uniqid();
     $template->{$otherChildTag->getTag()} = uniqid();
     $template->{$littleChildTag->getTag()} = uniqid();
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isNotEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isNotEmpty()->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()->string($littleChildTag->getData())->isNotEmpty();
     unset($template->{$childTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isNotEmpty()->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()->string($littleChildTag->getData())->isNotEmpty();
     unset($template->{$otherChildTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty()->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()->string($littleChildTag->getData())->isNotEmpty();
     unset($template->{$littleChildTag->getTag()});
     $this->assert->boolean(isset($template->{$childTag->getTag()}))->isTrue()->string($childTag->getData())->isEmpty()->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()->string($otherChildTag->getData())->isEmpty()->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()->string($littleChildTag->getData())->isEmpty();
 }
示例#4
0
 public function testGetById()
 {
     $this->if($this->newTestedInstance)->then->variable($this->testedInstance->getById(uniqid()))->isNull()->if($tag = new atoum\template\tag(uniqid()), $this->testedInstance->addChild($tag->setId($id = uniqid())))->then->variable($this->testedInstance->getById(uniqid()))->isNull()->object($this->testedInstance->getById($id))->isIdenticalTo($tag)->if($childTag = new atoum\template\tag(uniqid()), $tag->addChild($childTag->setId($childId = uniqid())))->then->variable($this->testedInstance->getById(uniqid()))->isNull()->object($this->testedInstance->getById($id))->isIdenticalTo($tag)->object($tag->getById($id))->isIdenticalTo($tag)->object($this->testedInstance->getById($childId))->isIdenticalTo($childTag)->object($tag->getById($childId))->isIdenticalTo($childTag)->object($childTag->getById($childId))->isIdenticalTo($childTag)->variable($childTag->getById($id, false))->isNull();
 }