Best Atoum code snippet using child.isEmpty
template.php
Source:template.php
...10 {11 $this12 ->if($this->newTestedInstance)13 ->then14 ->string($this->testedInstance->getData())->isEmpty()15 ->if($this->newTestedInstance($data = uniqid()))16 ->then17 ->string($this->testedInstance->getData())->isEqualTo($data)18 ;19 }20 public function test__toString()21 {22 $this23 ->if($this->newTestedInstance)24 ->then25 ->string($this->testedInstance->getData())->isEmpty()26 ->boolean($this->testedInstance->hasChildren())->isFalse()27 ->variable($this->testedInstance->getId())->isNull()28 ->variable($this->testedInstance->getTag())->isNull()29 ->if($this->newTestedInstance($data = uniqid()))30 ->then31 ->string($this->testedInstance->getData())->isEqualTo($data)32 ->boolean($this->testedInstance->hasChildren())->isFalse()33 ->variable($this->testedInstance->getId())->isNull()34 ->variable($this->testedInstance->getTag())->isNull()35 ;36 }37 public function test__get()38 {39 $this40 ->if($this->newTestedInstance)41 ->then42 ->object($iterator = $this->testedInstance->{uniqid()})->isInstanceOf('mageekguy\atoum\template\iterator')43 ->sizeOf($iterator)->isZero()44 ->if($this->testedInstance->addChild($childTag = new atoum\template\tag(uniqid())))45 ->then46 ->object($iterator = $this->testedInstance->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')47 ->sizeOf($iterator)->isEqualTo(1)48 ->object($iterator->current())->isIdenticalTo($childTag)49 ->if($this->testedInstance->addChild($otherChildTag = new atoum\template\tag($childTag->getTag())))50 ->then51 ->object($iterator = $this->testedInstance->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')52 ->sizeOf($iterator)->isEqualTo(2)53 ->object($iterator->current())->isIdenticalTo($childTag)54 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)55 ->if($this->testedInstance->addChild($anotherChildTag = new atoum\template\tag(uniqid())))56 ->then57 ->object($iterator = $this->testedInstance->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')58 ->sizeOf($iterator)->isEqualTo(2)59 ->object($iterator->current())->isIdenticalTo($childTag)60 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)61 ->object($iterator = $this->testedInstance->{$anotherChildTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')62 ->sizeOf($iterator)->isEqualTo(1)63 ->object($iterator->current())->isIdenticalTo($anotherChildTag)64 ->if($childTag->addChild($littleChildTag = new atoum\template\tag($childTag->getTag())))65 ->then66 ->object($iterator = $this->testedInstance->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')67 ->sizeOf($iterator)->isEqualTo(3)68 ->object($iterator->current())->isIdenticalTo($childTag)69 ->object($iterator->next()->current())->isIdenticalTo($littleChildTag)70 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)71 ->object($iterator = $this->testedInstance->{$anotherChildTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')72 ->sizeOf($iterator)->isEqualTo(1)73 ->object($iterator->current())->isIdenticalTo($anotherChildTag)74 ;75 }76 public function test__set()77 {78 $this79 ->if(80 $this->newTestedInstance,81 $this->testedInstance82 ->addChild($tag = new atoum\template\tag(uniqid()))83 ->{$tag->getTag()} = $data = uniqid()84 )85 ->then86 ->string($tag->getData())->isEqualTo($data)87 ->if(88 $tag->addChild($childTag = new atoum\template\tag($tag->getTag())),89 $this->testedInstance->{$tag->getTag()} = $data90 )91 ->then92 ->string($tag->getData())->isEqualTo($data)93 ->string($childTag->getData())->isEqualTo($data)94 ->if(95 $tag->addChild($otherChildTag = new atoum\template\tag(uniqid())),96 $this->testedInstance->{$otherChildTag->getTag()} = $otherData = uniqid()97 )98 ->then99 ->string($tag->getData())->isEqualTo($data)100 ->string($childTag->getData())->isEqualTo($data)101 ->string($otherChildTag->getData())->isEqualTo($otherData)102 ;103 }104 public function test__isset()105 {106 $this107 ->if($this->newTestedInstance)108 ->then109 ->boolean(isset($this->testedInstance->{uniqid()}))->isFalse()110 ->if($this->testedInstance->addChild($childTag = new atoum\template\tag(uniqid())))111 ->then112 ->boolean(isset($this->testedInstance->{uniqid()}))->isFalse()113 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()114 ->if($childTag->addChild($otherChildTag = new atoum\template\tag(uniqid())))115 ->then116 ->boolean(isset($this->testedInstance->{uniqid()}))->isFalse()117 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()118 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()119 ->if($childTag->addChild($littleChildTag = new atoum\template\tag(uniqid())))120 ->then121 ->boolean(isset($this->testedInstance->{uniqid()}))->isFalse()122 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()123 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()124 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()125 ;126 }127 public function test__unset()128 {129 $this130 ->if(131 $template = $this->newTestedInstance,132 $this->testedInstance->addChild($childTag = new atoum\template\tag(uniqid()))133 )134 ->then135 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()136 ->string($childTag->getData())->isEmpty()137 ->when(function() use ($template, $childTag) {138 unset($template->{$childTag->getTag()});139 }140 )141 ->then142 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()143 ->string($childTag->getData())->isEmpty()144 ->if($this->testedInstance->{$childTag->getTag()} = uniqid())145 ->then146 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()147 ->string($childTag->getData())->isNotEmpty()148 ->when(function() use ($template, $childTag) {149 unset($template->{$childTag->getTag()});150 }151 )152 ->then153 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()154 ->string($childTag->getData())->isEmpty()155 ->if($this->testedInstance->addChild($otherChildTag = new atoum\template\tag(uniqid())))156 ->then157 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()158 ->string($childTag->getData())->isEmpty()159 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()160 ->string($otherChildTag->getData())->isEmpty()161 ->when(function() use ($template, $childTag, $otherChildTag) {162 unset($template->{$childTag->getTag()});163 unset($template->{$otherChildTag->getTag()});164 }165 )166 ->then167 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()168 ->string($childTag->getData())->isEmpty()169 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()170 ->string($otherChildTag->getData())->isEmpty()171 ->if(172 $this->testedInstance->{$childTag->getTag()} = uniqid(),173 $this->testedInstance->{$otherChildTag->getTag()} = uniqid()174 )175 ->then176 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()177 ->string($childTag->getData())->isNotEmpty()178 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()179 ->string($otherChildTag->getData())->isNotEmpty()180 ->when(function() use ($template, $childTag) {181 unset($template->{$childTag->getTag()});182 }183 )184 ->then185 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()186 ->string($childTag->getData())->isEmpty()187 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()188 ->string($otherChildTag->getData())->isNotEmpty()189 ->when(function() use ($template, $otherChildTag) {190 unset($template->{$otherChildTag->getTag()});191 }192 )193 ->then194 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()195 ->string($childTag->getData())->isEmpty()196 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()197 ->string($otherChildTag->getData())->isEmpty()198 ->if($childTag->addChild($littleChildTag = new atoum\template\tag(uniqid())))199 ->then200 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()201 ->string($childTag->getData())->isEmpty()202 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()203 ->string($otherChildTag->getData())->isEmpty()204 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()205 ->string($littleChildTag->getData())->isEmpty()206 ->if(207 $this->testedInstance->{$childTag->getTag()} = uniqid(),208 $this->testedInstance->{$otherChildTag->getTag()} = uniqid(),209 $this->testedInstance->{$littleChildTag->getTag()} = uniqid()210 )211 ->then212 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()213 ->string($childTag->getData())->isNotEmpty()214 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()215 ->string($otherChildTag->getData())->isNotEmpty()216 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()217 ->string($littleChildTag->getData())->isNotEmpty()218 ->when(function() use ($template, $childTag) {219 unset($template->{$childTag->getTag()});220 }221 )222 ->then223 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()224 ->string($childTag->getData())->isEmpty()225 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()226 ->string($otherChildTag->getData())->isNotEmpty()227 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()228 ->string($littleChildTag->getData())->isNotEmpty()229 ->when(function() use ($template, $otherChildTag) {230 unset($template->{$otherChildTag->getTag()});231 }232 )233 ->then234 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()235 ->string($childTag->getData())->isEmpty()236 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()237 ->string($otherChildTag->getData())->isEmpty()238 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()239 ->string($littleChildTag->getData())->isNotEmpty()240 ->when(function() use ($template, $littleChildTag) {241 unset($template->{$littleChildTag->getTag()});242 }243 )244 ->then245 ->boolean(isset($this->testedInstance->{$childTag->getTag()}))->isTrue()246 ->string($childTag->getData())->isEmpty()247 ->boolean(isset($this->testedInstance->{$otherChildTag->getTag()}))->isTrue()248 ->string($otherChildTag->getData())->isEmpty()249 ->boolean(isset($this->testedInstance->{$littleChildTag->getTag()}))->isTrue()250 ->string($littleChildTag->getData())->isEmpty()251 ;252 }253 public function testGetRoot()254 {255 $this256 ->if($this->newTestedInstance)257 ->then258 ->object($this->testedInstance->getRoot())->isTestedInstance259 ->if($this->testedInstance->addChild($childTemplate = new atoum\template()))260 ->then261 ->object($this->testedInstance->getRoot())->isTestedInstance262 ->object($childTemplate->getRoot())->isTestedInstance263 ->if($childTemplate->addChild($littleChildTemplate = new atoum\template()))264 ->then265 ->object($this->testedInstance->getRoot())->isTestedInstance266 ->object($childTemplate->getRoot())->isTestedInstance267 ->object($littleChildTemplate->getRoot())->isTestedInstance268 ;269 }270 public function testGetParent()271 {272 $this273 ->if($this->newTestedInstance)274 ->then275 ->variable($this->testedInstance->getParent())->isNull()276 ->if($this->testedInstance->addChild($childTemplate = new atoum\template()))277 ->then278 ->variable($this->testedInstance->getParent())->isNull()279 ->object($childTemplate->getParent())->isTestedInstance280 ->if($childTemplate->addChild($littleChildTemplate = new atoum\template()))281 ->then282 ->variable($this->testedInstance->getParent())->isNull()283 ->object($childTemplate->getParent())->isTestedInstance284 ->object($littleChildTemplate->getParent())->isIdenticalTo($childTemplate)285 ;286 }287 public function testParentIsSet()288 {289 $this290 ->if($this->newTestedInstance)291 ->then292 ->boolean($this->testedInstance->parentIsSet())->isFalse()293 ->if($childTemplate = new atoum\template())294 ->then295 ->boolean($this->testedInstance->parentIsSet())->isFalse()296 ->boolean($childTemplate->parentIsSet())->isFalse()297 ->if($this->testedInstance->addChild($childTemplate))298 ->then299 ->boolean($this->testedInstance->parentIsSet())->isFalse()300 ->boolean($childTemplate->parentIsSet())->isTrue()301 ->if($littleChildTemplate = new atoum\template())302 ->then303 ->boolean($this->testedInstance->parentIsSet())->isFalse()304 ->boolean($childTemplate->parentIsSet())->isTrue()305 ->boolean($littleChildTemplate->parentIsSet())->isFalse()306 ->if($childTemplate->addChild($littleChildTemplate))307 ->then308 ->boolean($this->testedInstance->parentIsSet())->isFalse()309 ->boolean($childTemplate->parentIsSet())->isTrue()310 ->boolean($littleChildTemplate->parentIsSet())->isTrue()311 ;312 }313 public function testUnsetParent()314 {315 $this316 ->if($this->newTestedInstance)317 ->then318 ->boolean($this->testedInstance->parentIsSet())->isFalse()319 ->object($this->testedInstance->unsetParent())->isTestedInstance320 ->boolean($this->testedInstance->parentIsSet())->isFalse()321 ->if($this->testedInstance->addChild($childTemplate = new atoum\template()))322 ->then323 ->boolean($this->testedInstance->parentIsSet())->isFalse()324 ->boolean($childTemplate->parentIsSet())->isTrue()325 ->object($this->testedInstance->unsetParent())->isTestedInstance326 ->object($childTemplate->unsetParent())->isIdenticalTo($childTemplate)327 ->boolean($this->testedInstance->parentIsSet())->isFalse()328 ->boolean($childTemplate->parentIsSet())->isFalse()329 ;330 }331 public function testSetParent()332 {333 $this334 ->if($this->newTestedInstance)335 ->then336 ->boolean($this->testedInstance->parentIsSet())->isFalse()337 ->object($this->testedInstance->setParent(new atoum\template()))->isTestedInstance338 ->boolean($this->testedInstance->parentIsSet())->isTrue()339 ;340 }341 public function testGetData()342 {343 $this344 ->if($this->newTestedInstance)345 ->then346 ->string($this->testedInstance->getData())->isEmpty()347 ->if($this->newTestedInstance($data = uniqid()))348 ->then349 ->string($this->testedInstance->getData())->isEqualTo($data)350 ->if(351 $this->newTestedInstance,352 $this->testedInstance->setData($data = uniqid())353 )354 ->then355 ->string($this->testedInstance->getData())->isEqualTo($data)356 ->if($this->testedInstance->addChild(new atoum\template($otherData = uniqid())))357 ->then358 ->string($this->testedInstance->getData())->isEqualTo($data)359 ->if($this->testedInstance->build())360 ->then361 ->string($this->testedInstance->getData())->isEqualTo($data . $otherData)362 ;363 }364 public function testSetData()365 {366 $this367 ->if($this->newTestedInstance)368 ->then369 ->object($this->testedInstance->setData($data = uniqid()))->isTestedInstance370 ->string($this->testedInstance->getData())->isEqualTo($data)371 ;372 }373 public function testAddData()374 {375 $this376 ->if($this->newTestedInstance)377 ->then378 ->object($this->testedInstance->addData($data = uniqid()))->isTestedInstance379 ->string($this->testedInstance->getData())->isEqualTo($data)380 ->object($this->testedInstance->addData($data))->isTestedInstance381 ->string($this->testedInstance->getData())->isEqualTo($data . $data)382 ->object($this->testedInstance->addData($otherData = uniqid()))->isTestedInstance383 ->string($this->testedInstance->getData())->isEqualTo($data . $data . $otherData)384 ;385 }386 public function testResetData()387 {388 $this389 ->if($this->newTestedInstance)390 ->then391 ->string($this->testedInstance->getData())->isEmpty()392 ->object($this->testedInstance->resetData())->isTestedInstance393 ->string($this->testedInstance->getData())->isEmpty()394 ->if($this->newTestedInstance($data = uniqid()))395 ->then396 ->string($this->testedInstance->getData())->isEqualTo($data)397 ->object($this->testedInstance->resetData())->isTestedInstance398 ->string($this->testedInstance->getData())->isEmpty()399 ;400 }401 public function testGetId()402 {403 $this404 ->if($this->newTestedInstance)405 ->then406 ->variable($this->testedInstance->getId())->isNull()407 ;408 }409 public function testIsRoot()410 {411 $this412 ->if($this->newTestedInstance)413 ->then414 ->boolean($this->testedInstance->isRoot())->isTrue()415 ;416 }417 public function testIsChild()418 {419 $this420 ->if(421 $this->newTestedInstance,422 $childTemplate = new atoum\template()423 )424 ->then425 ->boolean($this->testedInstance->isChild($childTemplate))->isFalse()426 ->if($this->testedInstance->addChild($childTemplate))427 ->then428 ->boolean($this->testedInstance->isChild($childTemplate))->isTrue()429 ;430 }431 public function testGetTag()432 {433 $this434 ->if($this->newTestedInstance)435 ->then436 ->variable($this->testedInstance->getTag())->isNull()437 ;438 }439 public function testGetChildren()440 {441 $this442 ->if($this->newTestedInstance)443 ->then444 ->array($this->testedInstance->getChildren())->isEmpty()445 ->if($this->testedInstance->addChild($childTemplate = new atoum\template()))446 ->then447 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))448 ->if($this->testedInstance->addChild($otherChildTemplate = new atoum\template()))449 ->then450 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))451 ->if($childTemplate->addChild($littleChildTemplate = new atoum\template()))452 ->then453 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))454 ;455 }456 public function testAddChild()457 {458 $this459 ->if($this->newTestedInstance)460 ->then461 ->boolean($this->testedInstance->hasChildren())->isFalse()462 ->object($this->testedInstance->addChild($childTemplate = new atoum\template()))->isTestedInstance463 ->object($childTemplate->getParent())->isTestedInstance464 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))465 ->object($this->testedInstance->addChild($childTemplate))->isTestedInstance466 ->object($childTemplate->getParent())->isTestedInstance467 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))468 ->if(469 $otherTemplate = new atoum\template(),470 $otherTemplate->addChild($otherChildTemplate = new atoum\template())471 )472 ->then473 ->array($otherTemplate->getChildren())->isIdenticalTo(array($otherChildTemplate))474 ->object($otherChildTemplate->getParent())->isIdenticalTo($otherTemplate)475 ->object($this->testedInstance->addChild($otherChildTemplate))->isTestedInstance476 ->array($otherTemplate->getChildren())->isEmpty()477 ->object($otherChildTemplate->getParent())->isTestedInstance478 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))479 ->if(480 $this->newTestedInstance,481 $templateWithId = new atoum\template\tag(uniqid()),482 $templateWithId->setId($id = uniqid()),483 $templateWithSameId = clone $templateWithId484 )485 ->then486 ->boolean($this->testedInstance->hasChildren())->isFalse()487 ->object($this->testedInstance->addChild($templateWithId))->isTestedInstance488 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($templateWithId))489 ->object($this->testedInstance->addChild($templateWithId))->isTestedInstance490 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($templateWithId))491 ->exception(function($test) use ($templateWithSameId) {492 $test->testedInstance->addChild($templateWithSameId);493 }494 )495 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')496 ->hasMessage('Id \'' . $id . '\' is already defined')497 ;498 }499 public function testDeleteChild()500 {501 $this502 ->if(503 $this->newTestedInstance,504 $this->testedInstance->addChild($childTemplate = new atoum\template())505 )506 ->then507 ->object($childTemplate->getParent())->isTestedInstance508 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))509 ->object($this->testedInstance->deleteChild($childTemplate))->isTestedInstance510 ->variable($childTemplate->getParent())->isNull()511 ->array($this->testedInstance->getChildren())->isEmpty()512 ;513 }514 public function testHasChildren()515 {516 $this517 ->if($this->newTestedInstance)518 ->then519 ->boolean($this->testedInstance->hasChildren())->isFalse()520 ->if($this->testedInstance->addChild($childTemplate = new atoum\template()))521 ->then522 ->boolean($this->testedInstance->hasChildren())->isTrue()523 ->if($this->testedInstance->deleteChild($childTemplate))524 ->then525 ->boolean($this->testedInstance->hasChildren())->isFalse()526 ;527 }528 public function testGetByTag()529 {530 $this531 ->if($this->newTestedInstance)532 ->then533 ->object($iterator = $this->testedInstance->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')534 ->sizeOf($iterator)->isZero()535 ->if($this->testedInstance->addChild($tag = new atoum\template\tag(uniqid())))536 ->then537 ->object($iterator = $this->testedInstance->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')538 ->sizeOf($iterator)->isZero()539 ->object($iterator = $this->testedInstance->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')540 ->sizeOf($iterator)->isEqualTo(1)541 ->object($iterator->current())->isIdenticalTo($tag)542 ->if($this->testedInstance->addChild($otherTag = new atoum\template\tag($tag->getTag())))543 ->then544 ->object($iterator = $this->testedInstance->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')545 ->sizeOf($iterator)->isZero()546 ->object($iterator = $this->testedInstance->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')547 ->sizeOf($iterator)->isEqualTo(2)548 ->object($iterator->current())->isIdenticalTo($tag)549 ->object($iterator->next()->current())->isIdenticalTo($otherTag)550 ->if($tag->addChild($childTag = new atoum\template\tag($tag->getTag())))551 ->then552 ->object($iterator = $this->testedInstance->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')553 ->sizeOf($iterator)->isZero()554 ->object($iterator = $this->testedInstance->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')555 ->sizeOf($iterator)->isEqualTo(3)556 ->object($iterator->current())->isIdenticalTo($tag)557 ->object($iterator->next()->current())->isIdenticalTo($childTag)558 ->object($iterator->next()->current())->isIdenticalTo($otherTag)559 ;560 }561 public function testGetById()562 {563 $this564 ->if($this->newTestedInstance)565 ->then566 ->variable($this->testedInstance->getById(uniqid()))->isNull()567 ->if(568 $tag = new atoum\template\tag(uniqid()),569 $this->testedInstance->addChild($tag->setId($id = uniqid()))570 )571 ->then572 ->variable($this->testedInstance->getById(uniqid()))->isNull()573 ->object($this->testedInstance->getById($id))->isIdenticalTo($tag)574 ->if(575 $childTag = new atoum\template\tag(uniqid()),576 $tag->addChild($childTag->setId($childId = uniqid()))577 )578 ->then579 ->variable($this->testedInstance->getById(uniqid()))->isNull()580 ->object($this->testedInstance->getById($id))->isIdenticalTo($tag)581 ->object($tag->getById($id))->isIdenticalTo($tag)582 ->object($this->testedInstance->getById($childId))->isIdenticalTo($childTag)583 ->object($tag->getById($childId))->isIdenticalTo($childTag)584 ->object($childTag->getById($childId))->isIdenticalTo($childTag)585 ->variable($childTag->getById($id, false))->isNull()586 ;587 }588 public function testBuild()589 {590 $this591 ->if($this->newTestedInstance)592 ->then593 ->string($this->testedInstance->getData())->isEmpty()594 ->boolean($this->testedInstance->hasChildren())->isFalse()595 ->object($this->testedInstance->build())->isTestedInstance596 ->string($this->testedInstance->getData())->isEmpty()597 ->if($this->newTestedInstance($data = uniqid()))598 ->then599 ->string($this->testedInstance->getData())->isEqualTo($data)600 ->boolean($this->testedInstance->hasChildren())->isFalse()601 ->object($this->testedInstance->build())->isTestedInstance602 ->string($this->testedInstance->getData())->isEqualTo($data)603 ->object($this->testedInstance->build())->isTestedInstance604 ->string($this->testedInstance->getData())->isEqualTo($data)605 ->if($this->testedInstance->addChild($childTemplate = new atoum\template($childData = uniqid())))606 ->then607 ->string($this->testedInstance->getData())->isEqualTo($data)608 ->string($childTemplate->getData())->isEqualTo($childData)609 ->array($this->testedInstance->getChildren())->isIdenticalTo(array($childTemplate))610 ->object($this->testedInstance->build())->isTestedInstance...
ProductModelDescendantsIndexerSpec.php
Source:ProductModelDescendantsIndexerSpec.php
...43 VariantProductInterface $childProduct1,44 VariantProductInterface $childProduct245 ) {46 $productModel->getProducts()->willReturn($productChildren);47 $productChildren->isEmpty()->willReturn(false);48 $productChildren->first()->willReturn($childProduct1);49 $productChildren->toArray()->willReturn([$childProduct1, $childProduct2]);50 $productIndexer->indexAll([$childProduct1, $childProduct2], [])->shouldBeCalled();51 $productModel->getProductModels()->willReturn($productModelChildren);52 $productModelChildren->isEmpty()->willReturn(true);53 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();54 $this->index($productModel);55 }56 function it_indexes_a_product_model_descendants_that_are_product_models_and_variant_products(57 $productIndexer,58 $productModelIndexer,59 ProductModelInterface $rootProductModel,60 ProductModelInterface $childProductModel,61 VariantProductInterface $childVariantProduct1,62 VariantProductInterface $childVariantProduct2,63 ArrayCollection $emptyProductsChildren,64 ArrayCollection $rootProductModelChildren,65 ArrayCollection $emptyChildProductModelChildren,66 ArrayCollection $productVariantsChildren,67 \ArrayIterator $rootProductModelChildrenIterator68 ) {69 // Starting first recursion70 $rootProductModel->getProducts()->willReturn($emptyProductsChildren);71 // First recursion72 $emptyProductsChildren->isEmpty()->willReturn(true);73 // Starting second recursion74 $rootProductModel->getProductModels()->willReturn($rootProductModelChildren);75 // Second recursion - first round76 $rootProductModelChildren->isEmpty()->willReturn(false);77 $rootProductModelChildren->first()->willReturn($childProductModel);78 $rootProductModelChildren->toArray()->willReturn([$childProductModel]);79 $productModelIndexer->indexAll([$childProductModel], [])->shouldBeCalled();80 $rootProductModelChildren->getIterator()->willReturn($rootProductModelChildrenIterator);81 $rootProductModelChildrenIterator->rewind()->shouldBeCalled();82 $rootProductModelChildrenIterator->valid()->willReturn(true, false);83 $rootProductModelChildrenIterator->current()->willReturn($childProductModel);84 $rootProductModelChildrenIterator->next()->shouldBeCalled();85 $childProductModel->getProductModels()->willReturn($emptyChildProductModelChildren);86 $emptyChildProductModelChildren->isEmpty()->willReturn(true);87 // Second recursion - starting the second round88 $childProductModel->getProductModels()->willReturn($emptyChildProductModelChildren);89 $childProductModel->getProducts()->willReturn($productVariantsChildren);90 // Second recursion - second round - empty product models91 $emptyChildProductModelChildren->isEmpty()->willReturn(true);92 // Second recursion - second round - index product variants93 $productVariantsChildren->isEmpty()->willReturn(false);94 $productVariantsChildren->first()->willReturn($childVariantProduct1);95 $productVariantsChildren->toArray()->willReturn([$childVariantProduct1, $childVariantProduct2]);96 $productIndexer->indexAll([$childVariantProduct1, $childVariantProduct2], [])->shouldBeCalled();97 $this->index($rootProductModel);98 }99 function it_does_not_index_non_product_model_objects(100 $productIndexer,101 $productModelIndexer,102 \stdClass $aWrongObject103 ) {104 $productIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();105 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();106 $this->shouldThrow(\InvalidArgumentException::class)->during('index', [$aWrongObject]);107 }108 function it_bulk_indexes_the_descendants_of_a_list_of_product_models(109 $productIndexer,110 $productModelIndexer,111 ProductModelInterface $productModel1,112 ProductModelInterface $productModel2,113 VariantProductInterface $childProduct1,114 VariantProductInterface $childProduct2,115 VariantProductInterface $childProduct3,116 VariantProductInterface $childProduct4,117 ArrayCollection $productChildren1,118 ArrayCollection $productModelChildren1,119 ArrayCollection $productChildren2,120 ArrayCollection $productModelChildren2121 ) {122 $productModel1->getProducts()->willReturn($productChildren1);123 $productChildren1->isEmpty()->willReturn(false);124 $productChildren1->first()->willReturn($childProduct1);125 $productChildren1->toArray()->willReturn([$childProduct1, $childProduct2]);126 $productIndexer->indexAll([$childProduct1, $childProduct2], [])->shouldBeCalled();127 $productModel1->getProductModels()->willReturn($productModelChildren1);128 $productModelChildren1->isEmpty()->willReturn(true);129 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();130 $productModel2->getProducts()->willReturn($productChildren2);131 $productChildren2->isEmpty()->willReturn(false);132 $productChildren2->first()->willReturn($childProduct3);133 $productChildren2->toArray()->willReturn([$childProduct3, $childProduct4]);134 $productIndexer->indexAll([$childProduct3, $childProduct4], [])->shouldBeCalled();135 $productModel2->getProductModels()->willReturn($productModelChildren2);136 $productModelChildren2->isEmpty()->willReturn(true);137 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();138 $this->indexAll([$productModel1, $productModel2]);139 }140 function it_indexes_a_product_model_and_its_descendants_products_with_options(141 $productIndexer,142 ProductModelInterface $productModel,143 VariantProductInterface $productChild,144 ArrayCollection $children,145 \ArrayIterator $childrenIterator146 ) {147 $children->isEmpty()->willReturn(false);148 $children->first()->willReturn($productChild);149 $children->toArray()->willReturn([$productChild]);150 $children->getIterator()->willReturn($childrenIterator);151 $productModel->getProductModels()->willReturn(new ArrayCollection());152 $productModel->getProducts()->willReturn($children);153 $productIndexer->indexAll([$productChild], ['my_option_key' => 'my_option_value', 'my_option_key2' => 'my_option_value2'])->shouldBeCalled();154 $this->index($productModel, ['my_option_key' => 'my_option_value', 'my_option_key2' => 'my_option_value2']);155 }156 function it_indexes_a_product_model_and_its_descendants_product_models_with_options(157 $productModelIndexer,158 ProductModelInterface $productModel,159 ProductModelInterface $productModelChild,160 ArrayCollection $children,161 \ArrayIterator $childrenIterator162 ) {163 $children->isEmpty()->willReturn(false);164 $children->first()->willReturn($productModelChild);165 $children->toArray()->willReturn([$productModelChild]);166 $children->getIterator()->willReturn($childrenIterator);167 $productModel->getProductModels()->willReturn($children);168 $productModel->getProducts()->willReturn(new ArrayCollection());169 $productModelIndexer->indexAll([$productModelChild], ['my_option_key' => 'my_option_value', 'my_option_key2' => 'my_option_value2'])->shouldBeCalled();170 $this->index($productModel, ['my_option_key' => 'my_option_value', 'my_option_key2' => 'my_option_value2']);171 }172 function it_does_not_bulk_index_non_product_model_objects(173 $productIndexer,174 $productModelIndexer,175 \stdClass $aWrongObject1,176 \stdClass $aWrongObject2177 ) {178 $productIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();179 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();180 $this->shouldThrow(\InvalidArgumentException::class)181 ->during('indexAll', [[$aWrongObject1, $aWrongObject2]]);182 }183 function it_does_not_bulk_index_empty_arrays_of_product_models(184 $productIndexer,185 $productModelIndexer186 ) {187 $productIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();188 $productModelIndexer->indexAll(Argument::cetera())->shouldNotBeCalled();189 $this->indexAll([]);190 }191 function it_removes_the_descendants_of_a_product_model_that_are_variant_products(192 $productRemover,193 $productModelRemover,194 ProductModelInterface $productModel,195 ArrayCollection $productChildren,196 ArrayCollection $productModelChildren,197 VariantProductInterface $childProduct1,198 VariantProductInterface $childProduct2199 ) {200 $productModel->getProducts()->willReturn($productChildren);201 $productChildren->isEmpty()->willReturn(false);202 $productChildren->first()->willReturn($childProduct1);203 $productChildren->toArray()->willReturn([$childProduct1, $childProduct2]);204 $productRemover->removeAll([$childProduct1, $childProduct2])->shouldBeCalled();205 $productModel->getProductModels()->willReturn($productModelChildren);206 $productModelChildren->isEmpty()->willReturn(true);207 $productModelRemover->removeAll(Argument::cetera())->shouldNotBeCalled();208 $this->remove($productModel);209 }210 function it_removes_a_product_model_descendants_that_are_product_models_and_variant_products(211 $productRemover,212 $productModelRemover,213 ProductModelInterface $rootProductModel,214 ProductModelInterface $childProductModel,215 VariantProductInterface $childVariantProduct1,216 VariantProductInterface $childVariantProduct2,217 ArrayCollection $emptyProductsChildren,218 ArrayCollection $rootProductModelChildren,219 ArrayCollection $emptyChildProductModelChildren,220 ArrayCollection $productVariantsChildren,221 \ArrayIterator $rootProductModelChildrenIterator222 ) {223 // Starting first recursion224 $rootProductModel->getProducts()->willReturn($emptyProductsChildren);225 // First recursion226 $emptyProductsChildren->isEmpty()->willReturn(true);227 // Starting second recursion228 $rootProductModel->getProductModels()->willReturn($rootProductModelChildren);229 // Second recursion - first round230 $rootProductModelChildren->isEmpty()->willReturn(false);231 $rootProductModelChildren->first()->willReturn($childProductModel);232 $rootProductModelChildren->toArray()->willReturn([$childProductModel]);233 $productModelRemover->removeAll([$childProductModel]);234 $rootProductModelChildren->getIterator()->willReturn($rootProductModelChildrenIterator);235 $rootProductModelChildrenIterator->rewind()->shouldBeCalled();236 $rootProductModelChildrenIterator->valid()->willReturn(true, false);237 $rootProductModelChildrenIterator->current()->willReturn($childProductModel);238 $rootProductModelChildrenIterator->next()->shouldBeCalled();239 $childProductModel->getProductModels()->willReturn($emptyChildProductModelChildren);240 $emptyChildProductModelChildren->isEmpty()->willReturn(true);241 // Second recursion - starting the second round242 $childProductModel->getProductModels()->willReturn($emptyChildProductModelChildren);243 $childProductModel->getProducts()->willReturn($productVariantsChildren);244 // Second recursion - second round - empty product models245 $emptyChildProductModelChildren->isEmpty()->willReturn(true);246 // Second recursion - second round - index product variants247 $productVariantsChildren->isEmpty()->willReturn(false);248 $productVariantsChildren->first()->willReturn($childVariantProduct1);249 $productVariantsChildren->toArray()->willReturn([$childVariantProduct1, $childVariantProduct2]);250 $productRemover->removeAll([$childVariantProduct1, $childVariantProduct2])->shouldBeCalled();251 $this->remove($rootProductModel);252 }253 function it_bulk_removes_the_descendants_of_a_list_of_product_models(254 $productRemover,255 $productModelRemover,256 ProductModelInterface $productModel1,257 ProductModelInterface $productModel2,258 VariantProductInterface $childProduct1,259 VariantProductInterface $childProduct2,260 VariantProductInterface $childProduct3,261 VariantProductInterface $childProduct4,262 ArrayCollection $productChildren1,263 ArrayCollection $productModelChildren1,264 ArrayCollection $productChildren2,265 ArrayCollection $productModelChildren2266 ) {267 $productModel1->getProducts()->willReturn($productChildren1);268 $productChildren1->isEmpty()->willReturn(false);269 $productChildren1->first()->willReturn($childProduct1);270 $productChildren1->toArray()->willReturn([$childProduct1, $childProduct2]);271 $productRemover->removeAll([$childProduct1, $childProduct2])->shouldBeCalled();272 $productModel1->getProductModels()->willReturn($productModelChildren1);273 $productModelChildren1->isEmpty()->willReturn(true);274 $productModelRemover->removeAll(Argument::cetera())->shouldNotBeCalled();275 $productModel2->getProducts()->willReturn($productChildren2);276 $productChildren2->isEmpty()->willReturn(false);277 $productChildren2->first()->willReturn($childProduct3);278 $productChildren2->toArray()->willReturn([$childProduct3, $childProduct4]);279 $productRemover->removeAll([$childProduct3, $childProduct4])->shouldBeCalled();280 $productModel2->getProductModels()->willReturn($productModelChildren2);281 $productModelChildren2->isEmpty()->willReturn(true);282 $productModelRemover->removeAll(Argument::cetera())->shouldNotBeCalled();283 $this->removeAll([$productModel1, $productModel2]);284 }285 function it_does_not_bulk_remove_non_product_model_objects(286 $productRemover,287 $productModelRemover,288 \stdClass $aWrongObject1,289 \stdClass $aWrongObject2290 ) {291 $productRemover->removeAll(Argument::cetera())->shouldNotBeCalled();292 $productModelRemover->removeAll(Argument::cetera())->shouldNotBeCalled();293 $this->shouldThrow(\InvalidArgumentException::class)294 ->during('removeAll', [[$aWrongObject1, $aWrongObject2]]);295 }...
Html.php
Source:Html.php
...22{23 /** @var string element's name */24 private $name;25 /** @var bool is element empty? */26 private $isEmpty;27 /** @var array element's attributes */28 public $attrs = array();29 /** @var array of Html | string nodes */30 protected $children = array();31 /** @var bool use XHTML syntax? */32 public static $xhtml = FALSE;33 /** @var array empty (void) elements */34 public static $emptyElements = array(35 'img' => 1, 'hr' => 1, 'br' => 1, 'input' => 1, 'meta' => 1, 'area' => 1, 'embed' => 1, 'keygen' => 1,36 'source' => 1, 'base' => 1, 'col' => 1, 'link' => 1, 'param' => 1, 'basefont' => 1, 'frame' => 1,37 'isindex' => 1, 'wbr' => 1, 'command' => 1, 'track' => 1,38 );39 /**40 * Static factory.41 * @param string element name (or NULL)42 * @param array|string element's attributes or plain text content43 * @return self44 */45 public static function el($name = NULL, $attrs = NULL)46 {47 $el = new static;48 $parts = explode(' ', $name, 2);49 $el->setName($parts[0]);50 if (is_array($attrs)) {51 $el->attrs = $attrs;52 } elseif ($attrs !== NULL) {53 $el->setText($attrs);54 }55 if (isset($parts[1])) {56 foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i') as $m) {57 $el->attrs[$m[1]] = isset($m[3]) ? $m[3] : TRUE;58 }59 }60 return $el;61 }62 /**63 * Changes element's name.64 * @param string65 * @param bool Is element empty?66 * @return self67 * @throws Nette\InvalidArgumentException68 */69 public function setName($name, $isEmpty = NULL)70 {71 if ($name !== NULL && !is_string($name)) {72 throw new Nette\InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name)));73 }74 $this->name = $name;75 $this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : (bool) $isEmpty;76 return $this;77 }78 /**79 * Returns element's name.80 * @return string81 */82 public function getName()83 {84 return $this->name;85 }86 /**87 * Is element empty?88 * @return bool89 */90 public function isEmpty()91 {92 return $this->isEmpty;93 }94 /**95 * Sets multiple attributes.96 * @param array97 * @return self98 */99 public function addAttributes(array $attrs)100 {101 $this->attrs = array_merge($this->attrs, $attrs);102 return $this;103 }104 /**105 * Overloaded setter for element's attribute.106 * @param string HTML attribute name107 * @param mixed HTML attribute value108 * @return void109 */110 public function __set($name, $value)111 {112 $this->attrs[$name] = $value;113 }114 /**115 * Overloaded getter for element's attribute.116 * @param string HTML attribute name117 * @return mixed HTML attribute value118 */119 public function &__get($name)120 {121 return $this->attrs[$name];122 }123 /**124 * Overloaded tester for element's attribute.125 * @param string HTML attribute name126 * @return bool127 */128 public function __isset($name)129 {130 return isset($this->attrs[$name]);131 }132 /**133 * Overloaded unsetter for element's attribute.134 * @param string HTML attribute name135 * @return void136 */137 public function __unset($name)138 {139 unset($this->attrs[$name]);140 }141 /**142 * Overloaded setter for element's attribute.143 * @param string HTML attribute name144 * @param array (string) HTML attribute value or pair?145 * @return self146 */147 public function __call($m, $args)148 {149 $p = substr($m, 0, 3);150 if ($p === 'get' || $p === 'set' || $p === 'add') {151 $m = substr($m, 3);152 $m[0] = $m[0] | "\x20";153 if ($p === 'get') {154 return isset($this->attrs[$m]) ? $this->attrs[$m] : NULL;155 } elseif ($p === 'add') {156 $args[] = TRUE;157 }158 }159 if (count($args) === 0) { // invalid160 } elseif (count($args) === 1) { // set161 $this->attrs[$m] = $args[0];162 } elseif ((string) $args[0] === '') {163 $tmp = & $this->attrs[$m]; // appending empty value? -> ignore, but ensure it exists164 } elseif (!isset($this->attrs[$m]) || is_array($this->attrs[$m])) { // needs array165 $this->attrs[$m][$args[0]] = $args[1];166 } else {167 $this->attrs[$m] = array($this->attrs[$m], $args[0] => $args[1]);168 }169 return $this;170 }171 /**172 * Special setter for element's attribute.173 * @param string path174 * @param array query175 * @return self176 */177 public function href($path, $query = NULL)178 {179 if ($query) {180 $query = http_build_query($query, NULL, '&');181 if ($query !== '') {182 $path .= '?' . $query;183 }184 }185 $this->attrs['href'] = $path;186 return $this;187 }188 /**189 * Sets element's HTML content.190 * @param string raw HTML string191 * @return self192 * @throws Nette\InvalidArgumentException193 */194 public function setHtml($html)195 {196 if (is_array($html)) {197 throw new Nette\InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));198 }199 $this->removeChildren();200 $this->children[] = (string) $html;201 return $this;202 }203 /**204 * Returns element's HTML content.205 * @return string206 */207 public function getHtml()208 {209 $s = '';210 foreach ($this->children as $child) {211 if (is_object($child)) {212 $s .= $child->render();213 } else {214 $s .= $child;215 }216 }217 return $s;218 }219 /**220 * Sets element's textual content.221 * @param string222 * @return self223 * @throws Nette\InvalidArgumentException224 */225 public function setText($text)226 {227 if (!is_array($text) && !$text instanceof self) {228 $text = htmlspecialchars((string) $text, ENT_NOQUOTES, 'UTF-8');229 }230 return $this->setHtml($text);231 }232 /**233 * Returns element's textual content.234 * @return string235 */236 public function getText()237 {238 return html_entity_decode(strip_tags($this->getHtml()), ENT_QUOTES, 'UTF-8');239 }240 /**241 * Adds new element's child.242 * @param Html|string Html node or raw HTML string243 * @return self244 */245 public function add($child)246 {247 return $this->insert(NULL, $child);248 }249 /**250 * Creates and adds a new Html child.251 * @param string elements's name252 * @param array|string element's attributes or raw HTML string253 * @return self created element254 */255 public function create($name, $attrs = NULL)256 {257 $this->insert(NULL, $child = static::el($name, $attrs));258 return $child;259 }260 /**261 * Inserts child node.262 * @param int|NULL position of NULL for appending263 * @param Html|string Html node or raw HTML string264 * @param bool265 * @return self266 * @throws Nette\InvalidArgumentException267 */268 public function insert($index, $child, $replace = FALSE)269 {270 if ($child instanceof self || is_scalar($child)) {271 if ($index === NULL) { // append272 $this->children[] = $child;273 } else { // insert or replace274 array_splice($this->children, (int) $index, $replace ? 1 : 0, array($child));275 }276 } else {277 throw new Nette\InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child)));278 }279 return $this;280 }281 /**282 * Inserts (replaces) child node (\ArrayAccess implementation).283 * @param int|NULL position of NULL for appending284 * @param Html|string Html node or raw HTML string285 * @return void286 */287 public function offsetSet($index, $child)288 {289 $this->insert($index, $child, TRUE);290 }291 /**292 * Returns child node (\ArrayAccess implementation).293 * @param int294 * @return self|string295 */296 public function offsetGet($index)297 {298 return $this->children[$index];299 }300 /**301 * Exists child node? (\ArrayAccess implementation).302 * @param int303 * @return bool304 */305 public function offsetExists($index)306 {307 return isset($this->children[$index]);308 }309 /**310 * Removes child node (\ArrayAccess implementation).311 * @param int312 * @return void313 */314 public function offsetUnset($index)315 {316 if (isset($this->children[$index])) {317 array_splice($this->children, (int) $index, 1);318 }319 }320 /**321 * Returns children count.322 * @return int323 */324 public function count()325 {326 return count($this->children);327 }328 /**329 * Removed all children.330 * @return void331 */332 public function removeChildren()333 {334 $this->children = array();335 }336 /**337 * Iterates over a elements.338 * @return \ArrayIterator339 */340 public function getIterator()341 {342 if (func_num_args() && func_get_arg(0)) {343 throw new Nette\DeprecatedException(__METHOD__ . " doesn't support deep iterator any more.");344 }345 return new \ArrayIterator($this->children);346 }347 /**348 * Returns all of children.349 * @return array350 */351 public function getChildren()352 {353 return $this->children;354 }355 /**356 * Renders element's start tag, content and end tag.357 * @param int358 * @return string359 */360 public function render($indent = NULL)361 {362 $s = $this->startTag();363 if (!$this->isEmpty) {364 // add content365 if ($indent !== NULL) {366 $indent++;367 }368 foreach ($this->children as $child) {369 if (is_object($child)) {370 $s .= $child->render($indent);371 } else {372 $s .= $child;373 }374 }375 // add end tag376 $s .= $this->endTag();377 }378 if ($indent !== NULL) {379 return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));380 }381 return $s;382 }383 public function __toString()384 {385 return $this->render();386 }387 /**388 * Returns element's start tag.389 * @return string390 */391 public function startTag()392 {393 if ($this->name) {394 return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>');395 } else {396 return '';397 }398 }399 /**400 * Returns element's end tag.401 * @return string402 */403 public function endTag()404 {405 return $this->name && !$this->isEmpty ? '</' . $this->name . '>' : '';406 }407 /**408 * Returns element's attributes.409 * @return string410 * @internal411 */412 public function attributes()413 {414 if (!is_array($this->attrs)) {415 return '';416 }417 $s = '';418 $attrs = $this->attrs;419 if (isset($attrs['data']) && is_array($attrs['data'])) { // deprecated...
isEmpty
Using AI Code Generation
1$test = new Test();2$test->isEmpty();3$test = new Test();4$test->isEmpty();5$test = new Test();6$test->isEmpty();7$test = new Test();8$test->isEmpty();9$test = new Test();10$test->isEmpty();11$test = new Test();12$test->isEmpty();13$test = new Test();14$test->isEmpty();15$test = new Test();16$test->isEmpty();17$test = new Test();18$test->isEmpty();19$test = new Test();20$test->isEmpty();21$test = new Test();22$test->isEmpty();23$test = new Test();24$test->isEmpty();25$test = new Test();26$test->isEmpty();27$test = new Test();28$test->isEmpty();29$test = new Test();30$test->isEmpty();31$test = new Test();32$test->isEmpty();33$test = new Test();34$test->isEmpty();35$test = new Test();36$test->isEmpty();
isEmpty
Using AI Code Generation
1$object = new ChildClass();2$object->isEmpty();3$object = new ParentClass();4$object->isEmpty();5$object = new ChildClass();6$object->isEmpty();7$object = new ParentClass();8$object->isEmpty();9$object = new ChildClass();10$object->isEmpty();11$object = new ParentClass();12$object->isEmpty();
isEmpty
Using AI Code Generation
1$obj = new Child();2if($obj->isEmpty())3{4 echo "Empty";5}6{7 echo "Not Empty";8}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with isEmpty on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!