How to use isIdenticalTo method of child class

Best Atoum code snippet using child.isIdenticalTo

DbUtils.php

Source:DbUtils.php Github

copy

Full Screen

...66 $this67 ->if($this->newTestedInstance)68 ->then69 ->string($this->testedInstance->getForeignKeyFieldForTable($table))70 ->isIdenticalTo($key);71 //keep testing old method from db.function72 $this->string(getForeignKeyFieldForTable($table))->isIdenticalTo($key);73 }74 /**75 * @dataProvider dataTableForeignKey76 **/77 public function testIsForeignKeyFieldBase($table, $key) {78 $this79 ->if($this->newTestedInstance)80 ->then81 ->boolean($this->testedInstance->isForeignKeyField($key))->isTrue();82 //keep testing old method from db.function83 $this->boolean(isForeignKeyField($key))->isTrue();84 }85 public function testIsForeignKeyFieldMore() {86 $this87 ->if($this->newTestedInstance)88 ->then89 ->boolean($this->testedInstance->isForeignKeyField('FakeId'))->isFalse()90 ->boolean($this->testedInstance->isForeignKeyField('id_Another_Fake_Id'))->isFalse()91 ->boolean($this->testedInstance->isForeignKeyField('users_id_tech'))->isTrue()92 ->boolean($this->testedInstance->isForeignKeyField('_id'))->isFalse();93 //keep testing old method from db.function94 $this->boolean(isForeignKeyField('FakeId'))->isFalse();95 $this->boolean(isForeignKeyField('id_Another_Fake_Id'))->isFalse();96 $this->boolean(isForeignKeyField('users_id_tech'))->isTrue();97 $this->boolean(isForeignKeyField('_id'))->isFalse();98 }99 /**100 * @dataProvider dataTableForeignKey101 **/102 public function testGetTableNameForForeignKeyField($table, $key) {103 $this104 ->if($this->newTestedInstance)105 ->then106 ->string($this->testedInstance->getTableNameForForeignKeyField($key))->isIdenticalTo($table);107 //keep testing old method from db.function108 $this->string(getTableNameForForeignKeyField($key))->isIdenticalTo($table);109 }110 protected function dataTableType() {111 // Pseudo plugin class for test112 require_once __DIR__ . '/../fixtures/pluginfoobar.php';113 require_once __DIR__ . '/../fixtures/pluginbarfoo.php';114 return [['glpi_computers', 'Computer', true],115 ['glpi_events', 'Glpi\\Event', true],116 ['glpi_users', 'User', true],117 ['glpi_plugin_bar_foos', 'GlpiPlugin\\Bar\\Foo', true],118 ['glpi_plugin_baz_foos', 'GlpiPlugin\\Baz\\Foo', false],119 ['glpi_plugin_foo_bars', 'PluginFooBar', true],120 ['glpi_plugin_foo_bazs', 'PluginFooBaz', false]];121 }122 /**123 * @dataProvider dataTableType124 **/125 public function testGetTableForItemType($table, $type, $classexists) {126 $this127 ->if($this->newTestedInstance)128 ->then129 ->string($this->testedInstance->getTableForItemType($type))->isIdenticalTo($table);130 //keep testing old method from db.function131 $this->string(getTableForItemType($type))->isIdenticalTo($table);132 }133 /**134 * @dataProvider dataTableType135 **/136 public function testGetItemTypeForTable($table, $type, $classexists) {137 if ($classexists) {138 $this139 ->if($this->newTestedInstance)140 ->then141 ->string($this->testedInstance->getItemTypeForTable($table))->isIdenticalTo($type);142 } else {143 $this144 ->if($this->newTestedInstance)145 ->then146 ->string($this->testedInstance->getItemTypeForTable($table))->isIdenticalTo('UNKNOWN');147 }148 //keep testing old method from db.function149 if ($classexists) {150 $this->string(getItemTypeForTable($table))->isIdenticalTo($type);151 } else {152 $this->string(getItemTypeForTable($table))->isIdenticalTo('UNKNOWN');153 }154 }155 /**156 * @dataProvider dataTableType157 **/158 public function testGetItemForItemtype($table, $itemtype, $classexists) {159 if ($classexists) {160 $this161 ->if($this->newTestedInstance)162 ->then163 ->object($this->testedInstance->getItemForItemtype($itemtype))->isInstanceOf($itemtype);164 } else {165 $this166 ->if($this->newTestedInstance)167 ->then168 ->boolean($this->testedInstance->getItemForItemtype($itemtype))->isFalse();169 }170 //keep testing old method from db.function171 if ($classexists) {172 $this->object(getItemForItemtype($itemtype))173 ->isInstanceOf($itemtype);174 } else {175 $this->boolean(getItemForItemtype($itemtype))->isFalse();176 }177 }178 public function dataPlural() {179 return [180 ['model', 'models'],181 ['address', 'addresses'],182 ['computer', 'computers'],183 ['thing', 'things'],184 ['criteria', 'criterias'],185 ['version', 'versions'],186 ['config', 'configs'],187 ['machine', 'machines'],188 ['memory', 'memories'],189 ['licence', 'licences'],190 ['pdu', 'pdus']191 ];192 }193 /**194 * @dataProvider dataPlural195 */196 public function testGetPlural($singular, $plural) {197 $this198 ->if($this->newTestedInstance)199 ->then200 ->string($this->testedInstance->getPlural($singular))->isIdenticalTo($plural)201 ->string(202 $this->testedInstance->getPlural(203 $this->testedInstance->getPlural(204 $singular205 )206 )207 )->isIdenticalTo($plural);208 //keep testing old method from db.function209 $this->string(getPlural($singular))->isIdenticalTo($plural);210 $this->string(getPlural(getPlural($singular)))->isIdenticalTo($plural);211 }212 /**213 * @dataProvider dataPlural214 **/215 public function testGetSingular($singular, $plural) {216 $this217 ->if($this->newTestedInstance)218 ->then219 ->string($this->testedInstance->getSingular($plural))->isIdenticalTo($singular)220 ->string(221 $this->testedInstance->getSingular(222 $this->testedInstance->getSingular(223 $plural224 )225 )226 )->isIdenticalTo($singular);227 //keep testing old method from db.function228 $this->string(getSingular($plural))->isIdenticalTo($singular);229 $this->string(getSingular(getSingular($plural)))->isIdenticalTo($singular);230 }231 public function testCountElementsInTable() {232 $this233 ->if($this->newTestedInstance)234 ->then235 ->integer($this->testedInstance->countElementsInTable('glpi_configs'))->isGreaterThan(100)236 ->integer($this->testedInstance->countElementsInTable(['glpi_configs', 'glpi_users']))->isGreaterThan(100)237 ->integer($this->testedInstance->countElementsInTable('glpi_configs', "context = 'core'"))->isGreaterThan(100)238 ->integer($this->testedInstance->countElementsInTable('glpi_configs', ['context' => 'core']))->isGreaterThan(100)239 ->integer($this->testedInstance->countElementsInTable('glpi_configs', "context = 'core' AND name = 'version'"))->isIdenticalTo(1)240 ->integer($this->testedInstance->countElementsInTable('glpi_configs', ['context' => 'core', 'name' => 'version']))->isIdenticalTo(1)241 ->integer($this->testedInstance->countElementsInTable('glpi_configs', "context = 'fakecontext'"))->isIdenticalTo(0)242 ->integer($this->testedInstance->countElementsInTable('glpi_configs', ['context' => 'fakecontext']))->isIdenticalTo(0);243 //keep testing old method from db.function244 //the case of using an element that is not a table is not handle in the function :245 //testCountElementsInTable($table, $condition="")246 $this->integer(countElementsInTable('glpi_configs'))->isGreaterThan(100);247 $this->integer(countElementsInTable(['glpi_configs', 'glpi_users']))->isGreaterThan(100);248 $this->integer(countElementsInTable('glpi_configs', "context = 'core'"))->isGreaterThan(100);249 $this->integer(250 countElementsInTable(251 'glpi_configs', "context = 'core' AND `name` = 'version'"252 )253 )->isIdenticalTo(1);254 $this->integer(countElementsInTable('glpi_configs', "context = 'fakecontext'"))->isIdenticalTo(0);255 // Using iterator256 $this->integer(countElementsInTable('glpi_configs', ['context' => 'core', 'name' => 'version']))->isIdenticalTo(1);257 $this->integer(countElementsInTable('glpi_configs', ['context' => 'core']))->isGreaterThan(100);258 $this->integer(countElementsInTable('glpi_configs', ['context' => 'fakecontext']))->isIdenticalTo(0);259 }260 public function testCountDistinctElementsInTable() {261 $this262 ->if($this->newTestedInstance)263 ->then264 ->integer($this->testedInstance->countDistinctElementsInTable('glpi_configs', 'id'))->isGreaterThan(0)265 ->integer($this->testedInstance->countDistinctElementsInTable('glpi_configs', 'context'))->isGreaterThan(0)266 ->integer($this->testedInstance->countDistinctElementsInTable('glpi_tickets', 'entities_id'))->isIdenticalTo(2)267 ->integer($this->testedInstance->countDistinctElementsInTable('glpi_crontasks', 'itemtype', ['frequency' => '86400']))->isIdenticalTo(12)268 ->integer($this->testedInstance->countDistinctElementsInTable('glpi_crontasks', 'id', ['frequency' => '86400']))->isIdenticalTo(15)269 ->integer(270 countDistinctElementsInTable(271 'glpi_configs',272 'context',273 "name = 'version'"274 )275 )->isIdenticalTo(1)276 ->integer(277 countDistinctElementsInTable(278 'glpi_configs',279 'id',280 "context ='fakecontext'"281 )282 )->isIdenticalTo(0);283 //keep testing old method from db.function284 //the case of using an element that is not a table is not handle in the function :285 //testCountElementsInTable($table, $condition="")286 $this->integer(countDistinctElementsInTable('glpi_configs', 'id'))->isGreaterThan(0);287 $this->integer(countDistinctElementsInTable('glpi_configs', 'context'))->isGreaterThan(0);288 $this->integer(289 countDistinctElementsInTable(290 'glpi_configs',291 'context',292 "name = 'version'"293 )294 )->isIdenticalTo(1);295 $this->integer(296 countDistinctElementsInTable(297 'glpi_configs',298 'id',299 "context ='fakecontext'"300 )301 )->isIdenticalTo(0);302 }303 protected function dataCountMyEntities() {304 return [305 ['_test_root_entity', true, 'glpi_computers', '', 8],306 ['_test_root_entity', true, 'glpi_computers', ['name' => '_test_pc11'], 1],307 ['_test_root_entity', true, 'glpi_computers', ['name' => '_test_pc01'], 1],308 //test old syntax, once only309 ['_test_root_entity', true, 'glpi_computers', 'name="_test_pc11"', 1],310 ['_test_root_entity', false, 'glpi_computers', '', 3],311 ['_test_root_entity', false, 'glpi_computers', ['name' => '_test_pc11'], 0],312 ['_test_root_entity', false, 'glpi_computers', ['name' => '_test_pc01'], 1],313 ['_test_child_1', false, 'glpi_computers', '', 3],314 ['_test_child_1', false, 'glpi_computers', ['name' => '_test_pc11'], 1],315 ['_test_child_1', false, 'glpi_computers', ['name' => '_test_pc01'], 0],316 ];317 }318 /**319 * @dataProvider dataCountMyEntities320 */321 public function testCountElementsInTableForMyEntities(322 $entity,323 $recursive,324 $table,325 $condition,326 $count327 ) {328 $this->login();329 $this->setEntity($entity, $recursive);330 $this331 ->if($this->newTestedInstance)332 ->then333 ->integer($this->testedInstance->countElementsInTableForMyEntities($table, $condition))->isIdenticalTo($count);334 //keep testing old method from db.function335 $this->integer(countElementsInTableForMyEntities($table, $condition))->isIdenticalTo($count);336 }337 protected function dataCountEntities() {338 return [339 ['_test_root_entity', 'glpi_computers', '', 3],340 ['_test_root_entity', 'glpi_computers', ['name' => '_test_pc11'], 0],341 ['_test_root_entity', 'glpi_computers', ['name' => '_test_pc01'], 1],342 //test old syntax, once only343 ['_test_root_entity', 'glpi_computers', 'name="_test_pc11"', 0],344 ['_test_child_1', 'glpi_computers', '', 3],345 ['_test_child_1', 'glpi_computers', ['name' => '_test_pc11'], 1],346 ['_test_child_1', 'glpi_computers', ['name' => '_test_pc01'], 0],347 ];348 }349 /**350 * @dataProvider dataCountEntities351 */352 public function testCountElementsInTableForEntity(353 $entity,354 $table,355 $condition,356 $count357 ) {358 $eid = getItemByTypeName('Entity', $entity, true);359 $this360 ->if($this->newTestedInstance)361 ->then362 ->integer($this->testedInstance->countElementsInTableForEntity($table, $eid, $condition))->isIdenticalTo($count);363 //keep testing old method from db.function364 $this->integer(countElementsInTableForEntity($table, $eid, $condition))->isIdenticalTo($count);365 }366 public function testGetAllDatasFromTable() {367 $this368 ->if($this->newTestedInstance)369 ->then370 ->array($data = $this->testedInstance->getAllDataFromTable('glpi_configs'))371 ->size->isGreaterThan(100);372 foreach ($data as $key => $array) {373 $this->array($array)374 ->variable['id']->isEqualTo($key);375 }376 $this377 ->if($this->newTestedInstance)378 ->then379 ->array($this->testedInstance->getAllDataFromTable('glpi_configs', "context = 'core' AND `name` = 'version'"))->hasSize(1)380 ->array($this->testedInstance->getAllDataFromTable('glpi_configs', ['context' => 'core', 'name' => 'version']))->hasSize(1)381 ->array($data = $this->testedInstance->getAllDataFromTable('glpi_configs', "", false, 'name'))->isNotEmpty();382 $previousArrayName = "";383 foreach ($data as $key => $array) {384 $this->boolean($previousArrayName <= $previousArrayName = $array['name'])->isTrue();385 }386 //TODO: test with cache === true387 //keep testing old method from db.function388 $data = getAllDatasFromTable('glpi_configs');389 $this->array($data)390 ->size->isGreaterThan(100);391 foreach ($data as $key => $array) {392 $this->array($array)393 ->variable['id']->isEqualTo($key);394 }395 $data = getAllDatasFromTable('glpi_configs', "context = 'core' AND `name` = 'version'");396 $this->array($data)->hasSize(1);397 $data = getAllDatasFromTable('glpi_configs', "", false, 'name');398 $this->array($data)->isNotEmpty();399 $previousArrayName = "";400 foreach ($data as $key => $array) {401 $this->boolean($previousArrayName <= $previousArrayName = $array['name'])->isTrue();402 }403 }404 public function testTableExist() {405 $this->exception(406 function() {407 $this->boolean(TableExists('glpi_configs'))->isTrue();408 }409 )410 ->isInstanceOf('RuntimeException')411 ->message->contains('TableExists() function is deprecated');412 $this->exception(413 function() {414 $this->boolean(tableExists('fakeTable'))->isFalse();415 }416 )417 ->isInstanceOf('RuntimeException')418 ->message->contains('TableExists() function is deprecated');419 }420 public function testFieldExist() {421 $this->exception(422 function() {423 $this->boolean(fieldExists('glpi_configs', 'id'))->isTrue();424 }425 )426 ->isInstanceOf('RuntimeException')427 ->message->contains('FieldExists() function is deprecated');428 $this->exception(429 function() {430 $this->boolean(fieldExists('glpi_configs', 'fakeField'))->isFalse();431 }432 )433 ->isInstanceOf('RuntimeException')434 ->message->contains('FieldExists() function is deprecated');435 }436 public function testIsIndex() {437 $this438 ->if($this->newTestedInstance)439 ->then440 ->boolean($this->testedInstance->isIndex('glpi_configs', 'fakeField'))->isFalse()441 ->boolean($this->testedInstance->isIndex('glpi_configs', 'name'))->isFalse()442 ->boolean($this->testedInstance->isIndex('glpi_configs', 'value'))->isFalse()443 ->boolean($this->testedInstance->isIndex('glpi_users', 'locations_id'))->isTrue()444 ->boolean($this->testedInstance->isIndex('glpi_users', 'unicityloginauth'))->isTrue()445 ->when(446 function () {447 $this->boolean($this->testedInstance->isIndex('fakeTable', 'id'))->isFalse();448 }449 )->error450 ->withType(E_USER_WARNING)451 ->exists();452 //keep testing old method from db.function453 $this->boolean(isIndex('glpi_configs', 'fakeField'))->isFalse();454 $this->boolean(isIndex('glpi_configs', 'name'))->isFalse();455 $this->boolean(isIndex('glpi_users', 'locations_id'))->isTrue();456 $this->boolean(isIndex('glpi_users', 'unicityloginauth'))->isTrue();457 $this->when(458 function () {459 $this->boolean(isIndex('fakeTable', 'id'))->isFalse();460 }461 )->error462 ->withType(E_USER_WARNING)463 ->exists();464 }465 public function testGetEntityRestrict() {466 $this->login();467 $this->newTestedInstance();468 // See all, really all469 $_SESSION['glpishowallentities'] = 1; // will be restored by setEntity call470 $this->string($this->testedInstance->getEntitiesRestrictRequest('AND', 'glpi_computers'))->isEmpty();471 $it = new \DBmysqlIterator(null);472 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers'));473 $this->string($it->getSql())->isIdenticalTo('SELECT * FROM `glpi_computers`');474 //keep testing old method from db.function475 $this->string(getEntitiesRestrictRequest('AND', 'glpi_computers'))->isEmpty();476 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers'));477 $this->string($it->getSql())->isIdenticalTo('SELECT * FROM `glpi_computers`');478 // See all479 $this->setEntity('_test_root_entity', true);480 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE', 'glpi_computers'))481 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('1', '2', '3') ) ");482 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers'));483 $this->string($it->getSql())484 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'1\', \'2\', \'3\')');485 //keep testing old method from db.function486 $this->string(getEntitiesRestrictRequest('WHERE', 'glpi_computers'))487 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('1', '2', '3') ) ");488 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers'));489 $this->string($it->getSql())490 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'1\', \'2\', \'3\')');491 // Root entity492 $this->setEntity('_test_root_entity', false);493 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE', 'glpi_computers'))494 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('1') ) ");495 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers'));496 $this->string($it->getSql())497 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'1\')');498 //keep testing old method from db.function499 $this->string(getEntitiesRestrictRequest('WHERE', 'glpi_computers'))500 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('1') ) ");501 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers'));502 $this->string($it->getSql())503 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'1\')');504 // Child505 $this->setEntity('_test_child_1', false);506 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE', 'glpi_computers'))507 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('2') ) ");508 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers'));509 $this->string($it->getSql())510 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'2\')');511 //keep testing old method from db.function512 $this->string(getEntitiesRestrictRequest('WHERE', 'glpi_computers'))513 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('2') ) ");514 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers'));515 $this->string($it->getSql())516 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `glpi_computers`.`entities_id` IN (\'2\')');517 // Child without table518 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE'))519 ->isIdenticalTo("WHERE ( `entities_id` IN ('2') ) ");520 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria());521 $this->string($it->getSql())522 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `entities_id` IN (\'2\')');523 //keep testing old method from db.function524 $this->string(getEntitiesRestrictRequest('WHERE'))525 ->isIdenticalTo("WHERE ( `entities_id` IN ('2') ) ");526 $it->execute('glpi_computers', getEntitiesRestrictCriteria());527 $this->string($it->getSql())528 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE `entities_id` IN (\'2\')');529 // Child + parent530 $this->setEntity('_test_child_2', false);531 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE', 'glpi_computers', '', '', true))532 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('3') OR (`glpi_computers`.`is_recursive`='1' AND `glpi_computers`.`entities_id` IN ('0','1')) ) ");533 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers', '', '', true));534 $this->string($it->getSql())535 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`glpi_computers`.`entities_id` IN (\'3\') OR (`glpi_computers`.`is_recursive` = \'1\' AND `glpi_computers`.`entities_id` IN (\'0\', \'1\')))');536 //keep testing old method from db.function537 $this->string(getEntitiesRestrictRequest('WHERE', 'glpi_computers', '', '', true))538 ->isIdenticalTo("WHERE ( `glpi_computers`.`entities_id` IN ('3') OR (`glpi_computers`.`is_recursive`='1' AND `glpi_computers`.`entities_id` IN ('0','1')) ) ");539 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers', '', '', true));540 $this->string($it->getSql())541 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`glpi_computers`.`entities_id` IN (\'3\') OR (`glpi_computers`.`is_recursive` = \'1\' AND `glpi_computers`.`entities_id` IN (\'0\', \'1\')))');542 //Child + parent on glpi_entities543 $it->execute('glpi_entities', $this->testedInstance->getEntitiesRestrictCriteria('glpi_entities', '', '', true));544 $this->string($it->getSql())545 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE (`glpi_entities`.`id` IN (\'3\', \'0\', \'1\'))');546 //keep testing old method from db.function547 $it->execute('glpi_entities', getEntitiesRestrictCriteria('glpi_entities', '', '', true));548 $this->string($it->getSql())549 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE (`glpi_entities`.`id` IN (\'3\', \'0\', \'1\'))');550 //Child + parent -- automatic recusrivity detection551 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('glpi_computers', '', '', 'auto'));552 $this->string($it->getSql())553 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`glpi_computers`.`entities_id` IN (\'3\') OR (`glpi_computers`.`is_recursive` = \'1\' AND `glpi_computers`.`entities_id` IN (\'0\', \'1\')))');554 //keep testing old method from db.function555 $it->execute('glpi_computers', getEntitiesRestrictCriteria('glpi_computers', '', '', 'auto'));556 $this->string($it->getSql())557 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`glpi_computers`.`entities_id` IN (\'3\') OR (`glpi_computers`.`is_recursive` = \'1\' AND `glpi_computers`.`entities_id` IN (\'0\', \'1\')))');558 // Child + parent without table559 $this->string($this->testedInstance->getEntitiesRestrictRequest('WHERE', '', '', '', true))560 ->isIdenticalTo("WHERE ( `entities_id` IN ('3') OR (`is_recursive`='1' AND `entities_id` IN ('0','1')) ) ");561 $it->execute('glpi_computers', $this->testedInstance->getEntitiesRestrictCriteria('', '', '', true));562 $this->string($it->getSql())563 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`entities_id` IN (\'3\') OR (`is_recursive` = \'1\' AND `entities_id` IN (\'0\', \'1\')))');564 $it->execute('glpi_entities', $this->testedInstance->getEntitiesRestrictCriteria('glpi_entities', '', 3, true));565 $this->string($it->getSql())566 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE (`glpi_entities`.`id` IN (\'3\', \'0\', \'1\'))');567 $it->execute('glpi_entities', $this->testedInstance->getEntitiesRestrictCriteria('glpi_entities', '', 7, true));568 $this->string($it->getSql())569 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE `glpi_entities`.`id` = \'7\'');570 //keep testing old method from db.function571 $this->string(getEntitiesRestrictRequest('WHERE', '', '', '', true))572 ->isIdenticalTo("WHERE ( `entities_id` IN ('3') OR (`is_recursive`='1' AND `entities_id` IN ('0','1')) ) ");573 $it->execute('glpi_computers', getEntitiesRestrictCriteria('', '', '', true));574 $this->string($it->getSql())575 ->isIdenticalTo('SELECT * FROM `glpi_computers` WHERE (`entities_id` IN (\'3\') OR (`is_recursive` = \'1\' AND `entities_id` IN (\'0\', \'1\')))');576 $it->execute('glpi_entities', getEntitiesRestrictCriteria('glpi_entities', '', 3, true));577 $this->string($it->getSql())578 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE (`glpi_entities`.`id` IN (\'3\', \'0\', \'1\'))');579 $it->execute('glpi_entities', getEntitiesRestrictCriteria('glpi_entities', '', 7, true));580 $this->string($it->getSql())581 ->isIdenticalTo('SELECT * FROM `glpi_entities` WHERE `glpi_entities`.`id` = \'7\'');582 }583 /**584 * Run getAncestorsOf tests585 *586 * @param boolean $cache Is cache enabled?587 * @param boolean $hit Do we expect a cache hit? (ie. data already exists)588 *589 * @return void590 */591 private function runGetAncestorsOf($cache = false, $hit = false) {592 $ent0 = getItemByTypeName('Entity', '_test_root_entity', true);593 $ent1 = getItemByTypeName('Entity', '_test_child_1', true);594 $ent2 = getItemByTypeName('Entity', '_test_child_2', true);595 //Cache tests:596 //- if $cache === 0; we do not expect anything,597 //- if $cache === 1; we expect cache to be empty before call, and populated after598 //- if $hit === 1; we expect cache to be populated599 $ckey = $this->nscache . ':glpi_entities_ancestors_cache_';600 //test on ent0601 $expected = [0 => '0'];602 if ($cache === true && $hit === false) {603 $this->boolean(apcu_exists($ckey . $ent0))->isFalse();604 } else if ($cache === true && $hit === true) {605 $this->array(apcu_fetch("$ckey$ent0"))->isIdenticalTo($expected);606 }607 $ancestors = getAncestorsOf('glpi_entities', $ent0);608 $this->array($ancestors)->isIdenticalTo($expected);609 if ($cache === true && $hit === false) {610 $this->array(apcu_fetch("$ckey$ent0"))->isIdenticalTo($expected);611 }612 //test on ent1613 $expected = [0 => '0', 1 => "$ent0"];614 if ($cache === true && $hit === false) {615 $this->boolean(apcu_exists($ckey . $ent1))->isFalse();616 } else if ($cache === true && $hit === true) {617 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);618 }619 $ancestors = getAncestorsOf('glpi_entities', $ent1);620 $this->array($ancestors)->isIdenticalTo($expected);621 if ($cache === true && $hit === false) {622 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);623 }624 //test on ent2625 $expected = [0 => '0', 1 => "$ent0"];626 if ($cache === true && $hit === false) {627 $this->boolean(apcu_exists($ckey . $ent2))->isFalse();628 } else if ($cache === true && $hit === true) {629 $this->array(apcu_fetch("$ckey$ent2"))->isIdenticalTo($expected);630 }631 $ancestors = getAncestorsOf('glpi_entities', $ent2);632 $this->array($ancestors)->isIdenticalTo($expected);633 if ($cache === true && $hit === false) {634 $this->array(apcu_fetch("$ckey$ent2"))->isIdenticalTo($expected);635 }636 //test with new sub entity637 //Cache tests:638 //APCu cache is updated on entity creation; so even if we do not expect $hit; we got it.639 $new_id = getItemByTypeName('Entity', 'Sub child entity', true);640 if (!$new_id) {641 $entity = new \Entity();642 $new_id = (int)$entity->add([643 'name' => 'Sub child entity',644 'entities_id' => $ent1645 ]);646 $this->integer($new_id)->isGreaterThan(0);647 }648 $expected = [0 => '0', $ent0 => "$ent0", $ent1 => "$ent1"];649 if ($cache === true) {650 $this->array(apcu_fetch("$ckey$new_id"))->isIdenticalTo($expected);651 }652 $ancestors = getAncestorsOf('glpi_entities', $new_id);653 $this->array($ancestors)->isIdenticalTo($expected);654 if ($cache === true && $hit === false) {655 $this->array(apcu_fetch("$ckey$new_id"))->isIdenticalTo($expected);656 }657 //test with another new sub entity658 $new_id2 = getItemByTypeName('Entity', 'Sub child entity 2', true);659 if (!$new_id2) {660 $entity = new \Entity();661 $new_id2 = (int)$entity->add([662 'name' => 'Sub child entity 2',663 'entities_id' => $ent2664 ]);665 $this->integer($new_id2)->isGreaterThan(0);666 }667 $expected = [0 => '0', $ent0 => "$ent0", $ent2 => "$ent2"];668 if ($cache === true) {669 $this->array(apcu_fetch("$ckey$new_id2"))->isIdenticalTo($expected);670 }671 $ancestors = getAncestorsOf('glpi_entities', $new_id2);672 $this->array($ancestors)->isIdenticalTo($expected);673 if ($cache === true && $hit === false) {674 $this->array(apcu_fetch("$ckey$new_id2"))->isIdenticalTo($expected);675 }676 //test on multiple entities677 $expected = [0 => '0', $ent0 => "$ent0", $ent1 => "$ent1", $ent2 => "$ent2"];678 if ($cache === true && $hit === false) {679 $this->boolean(apcu_exists($ckey . $new_id . '|' . $new_id2))->isFalse();680 } else if ($cache === true && $hit === true) {681 $this->array(apcu_fetch("$ckey$new_id|$new_id2"))->isIdenticalTo($expected);682 }683 $ancestors = getAncestorsOf('glpi_entities', [$new_id, $new_id2]);684 $this->array($ancestors)->isIdenticalTo($expected);685 if ($cache === true && $hit === false) {686 $this->array(apcu_fetch("$ckey$new_id|$new_id2"))->isIdenticalTo($expected);687 }688 }689 public function testGetAncestorsOf() {690 global $DB;691 //ensure db cache is unset692 $DB->update('glpi_entities', ['ancestors_cache' => null], [true]);693 $this->runGetAncestorsOf();694 $this->integer(countElementsInTable('glpi_entities', ['ancestors_cache' => 'NULL']))->isIdenticalTo(0);695 //run a second time: db cache must be set696 $this->runGetAncestorsOf();697 }698 /**699 * @extensions apcu700 */701 public function testGetAncestorsOfCached() {702 //run with cache703 //first run: no cache hit expected704 $this->runGetAncestorsOf(true);705 //second run: cache hit expected706 $this->runGetAncestorsOf(true, true);707 }708 /**709 * Run getSonsOf tests710 *711 * @param boolean $cache Is cache enabled?712 * @param boolean $hit Do we expect a cache hit? (ie. data already exists)713 *714 * @return void715 */716 private function runGetSonsOf($cache = false, $hit = false) {717 $ent0 = getItemByTypeName('Entity', '_test_root_entity', true);718 $ent1 = getItemByTypeName('Entity', '_test_child_1', true);719 $ent2 = getItemByTypeName('Entity', '_test_child_2', true);720 $this->newTestedInstance();721 //Cache tests:722 //- if $cache === 0; we do not expect anything,723 //- if $cache === 1; we expect cache to be empty before call, and populated after724 //- if $hit === 1; we expect cache to be populated725 $ckey = $this->nscache . ':glpi_entities_sons_cache_';726 //test on ent0727 $expected = [$ent0 => "$ent0", $ent1 => "$ent1", $ent2 => "$ent2"];728 if ($cache === true && $hit === false) {729 $this->boolean(apcu_exists($ckey . $ent0))->isFalse();730 } else if ($cache === true && $hit === true) {731 $this->array(apcu_fetch("$ckey$ent0"))->isIdenticalTo($expected);732 }733 $sons = $this->testedInstance->getSonsOf('glpi_entities', $ent0);734 $this->array($sons)->isIdenticalTo($expected);735 if ($cache === true && $hit === false) {736 $this->array(apcu_fetch("$ckey$ent0"))->isIdenticalTo($expected);737 }738 //test on ent1739 $expected = [$ent1 => "$ent1"];740 if ($cache === true && $hit === false) {741 $this->boolean(apcu_exists($ckey . $ent1))->isFalse();742 } else if ($cache === true && $hit === true) {743 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);744 }745 $sons = $this->testedInstance->getSonsOf('glpi_entities', $ent1);746 $this->array($sons)->isIdenticalTo($expected);747 if ($cache === true && $hit === false) {748 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);749 }750 //test on ent2751 $expected = [$ent2 => "$ent2"];752 if ($cache === true && $hit === false) {753 $this->boolean(apcu_exists($ckey . $ent2))->isFalse();754 } else if ($cache === true && $hit === true) {755 $this->array(apcu_fetch("$ckey$ent2"))->isIdenticalTo($expected);756 }757 $sons = $this->testedInstance->getSonsOf('glpi_entities', $ent2);758 $this->array($sons)->isIdenticalTo($expected);759 if ($cache === true && $hit === false) {760 $this->array(apcu_fetch("$ckey$ent2"))->isIdenticalTo($expected);761 }762 //test with new sub entity763 //Cache tests:764 //APCu cache is updated on entity creation; so even if we do not expect $hit; we got it.765 $new_id = getItemByTypeName('Entity', 'Sub child entity', true);766 if (!$new_id) {767 $entity = new \Entity();768 $new_id = (int)$entity->add([769 'name' => 'Sub child entity',770 'entities_id' => $ent1771 ]);772 $this->integer($new_id)->isGreaterThan(0);773 }774 $expected = [$ent1 => $ent1, $new_id => "$new_id"];775 if ($cache === true) {776 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);777 }778 $sons = $this->testedInstance->getSonsOf('glpi_entities', $ent1);779 $this->array($sons)->isIdenticalTo($expected);780 if ($cache === true && $hit === false) {781 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);782 }783 //test with another new sub entity784 $new_id2 = getItemByTypeName('Entity', 'Sub child entity 2', true);785 if (!$new_id2) {786 $entity = new \Entity();787 $new_id2 = (int)$entity->add([788 'name' => 'Sub child entity 2',789 'entities_id' => $ent1790 ]);791 $this->integer($new_id2)->isGreaterThan(0);792 }793 $expected = [$ent1 => $ent1, $new_id => "$new_id", $new_id2 => "$new_id2"];794 if ($cache === true) {795 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);796 }797 $sons = $this->testedInstance->getSonsOf('glpi_entities', $ent1);798 $this->array($sons)->isIdenticalTo($expected);799 if ($cache === true && $hit === false) {800 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);801 }802 //drop sub entity803 $expected = [$ent1 => $ent1, $new_id2 => "$new_id2"];804 $this->boolean($entity->delete(['id' => $new_id], true))->isTrue();805 if ($cache === true) {806 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);807 }808 $expected = [$ent1 => $ent1];809 $this->boolean($entity->delete(['id' => $new_id2], true))->isTrue();810 if ($cache === true) {811 $this->array(apcu_fetch("$ckey$ent1"))->isIdenticalTo($expected);812 }813 }814 public function testGetSonsOf() {815 global $DB;816 //ensure db cache is unset817 $DB->update('glpi_entities', ['sons_cache' => null], [true]);818 $this->runGetSonsOf();819 $this->integer($this->testedInstance->countElementsInTable('glpi_entities', ['sons_cache' => 'NULL']))->isIdenticalTo(0);820 //run a second time: db cache must be set821 $this->runGetSonsOf();822 }823 /**824 * @extensions apcu825 */826 public function testGetSonsOfCached() {827 //run with cache828 //first run: no cache hit expected829 $this->runGetSonsOf(true);830 //second run: cache hit expected831 $this->runGetSonsOf(true, true);832 }833}...

Full Screen

Full Screen

template.php

Source:template.php Github

copy

Full Screen

...44 $template->addChild($childTag = new atoum\template\tag(uniqid()));45 $this->assert46 ->object($iterator = $template->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')47 ->sizeOf($iterator)->isEqualTo(1)48 ->object($iterator->current())->isIdenticalTo($childTag)49 ;50 $template->addChild($otherChildTag = new atoum\template\tag($childTag->getTag()));51 $this->assert52 ->object($iterator = $template->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')53 ->sizeOf($iterator)->isEqualTo(2)54 ->object($iterator->current())->isIdenticalTo($childTag)55 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)56 ;57 $template->addChild($anotherChildTag = new atoum\template\tag(uniqid()));58 $this->assert59 ->object($iterator = $template->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')60 ->sizeOf($iterator)->isEqualTo(2)61 ->object($iterator->current())->isIdenticalTo($childTag)62 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)63 ->object($iterator = $template->{$anotherChildTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')64 ->sizeOf($iterator)->isEqualTo(1)65 ->object($iterator->current())->isIdenticalTo($anotherChildTag)66 ;67 $childTag->addChild($littleChildTag = new atoum\template\tag($childTag->getTag()));68 $this->assert69 ->object($iterator = $template->{$childTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')70 ->sizeOf($iterator)->isEqualTo(3)71 ->object($iterator->current())->isIdenticalTo($childTag)72 ->object($iterator->next()->current())->isIdenticalTo($littleChildTag)73 ->object($iterator->next()->current())->isIdenticalTo($otherChildTag)74 ->object($iterator = $template->{$anotherChildTag->getTag()})->isInstanceOf('mageekguy\atoum\template\iterator')75 ->sizeOf($iterator)->isEqualTo(1)76 ->object($iterator->current())->isIdenticalTo($anotherChildTag)77 ;78 }79 public function test__set()80 {81 $template = new atoum\template();82 $template83 ->addChild($tag = new atoum\template\tag(uniqid()))84 ->{$tag->getTag()} = $data = uniqid()85 ;86 $this->assert87 ->string($tag->getData())->isEqualTo($data)88 ;89 $tag->addChild($childTag = new atoum\template\tag($tag->getTag()));90 $template->{$tag->getTag()} = $data;91 $this->assert92 ->string($tag->getData())->isEqualTo($data)93 ->string($childTag->getData())->isEqualTo($data)94 ;95 $tag->addChild($otherChildTag = new atoum\template\tag(uniqid()));96 $template->{$otherChildTag->getTag()} = $otherData = uniqid();97 $this->assert98 ->string($tag->getData())->isEqualTo($data)99 ->string($childTag->getData())->isEqualTo($data)100 ->string($otherChildTag->getData())->isEqualTo($otherData)101 ;102 }103 public function test__isset()104 {105 $template = new atoum\template();106 $this->assert107 ->boolean(isset($template->{uniqid()}))->isFalse()108 ;109 $template->addChild($childTag = new atoum\template\tag(uniqid()));110 $this->assert111 ->boolean(isset($template->{uniqid()}))->isFalse()112 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()113 ;114 $childTag->addChild($otherChildTag = new atoum\template\tag(uniqid()));115 $this->assert116 ->boolean(isset($template->{uniqid()}))->isFalse()117 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()118 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()119 ;120 $childTag->addChild($littleChildTag = new atoum\template\tag(uniqid()));121 $this->assert122 ->boolean(isset($template->{uniqid()}))->isFalse()123 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()124 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()125 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()126 ;127 }128 public function test__unset()129 {130 $template = new atoum\template();131 $template->addChild($childTag = new atoum\template\tag(uniqid()));132 $this->assert133 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()134 ->string($childTag->getData())->isEmpty()135 ;136 unset($template->{$childTag->getTag()});137 $this->assert138 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()139 ->string($childTag->getData())->isEmpty()140 ;141 $template->{$childTag->getTag()} = uniqid();142 $this->assert143 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()144 ->string($childTag->getData())->isNotEmpty()145 ;146 unset($template->{$childTag->getTag()});147 $this->assert148 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()149 ->string($childTag->getData())->isEmpty()150 ;151 $template->addChild($otherChildTag = new atoum\template\tag(uniqid()));152 $this->assert153 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()154 ->string($childTag->getData())->isEmpty()155 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()156 ->string($otherChildTag->getData())->isEmpty()157 ;158 unset($template->{$childTag->getTag()});159 unset($template->{$otherChildTag->getTag()});160 $this->assert161 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()162 ->string($childTag->getData())->isEmpty()163 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()164 ->string($otherChildTag->getData())->isEmpty()165 ;166 $template->{$childTag->getTag()} = uniqid();167 $template->{$otherChildTag->getTag()} = uniqid();168 $this->assert169 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()170 ->string($childTag->getData())->isNotEmpty()171 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()172 ->string($otherChildTag->getData())->isNotEmpty()173 ;174 unset($template->{$childTag->getTag()});175 $this->assert176 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()177 ->string($childTag->getData())->isEmpty()178 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()179 ->string($otherChildTag->getData())->isNotEmpty()180 ;181 unset($template->{$otherChildTag->getTag()});182 $this->assert183 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()184 ->string($childTag->getData())->isEmpty()185 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()186 ->string($otherChildTag->getData())->isEmpty()187 ;188 $childTag->addChild($littleChildTag = new atoum\template\tag(uniqid()));189 $this->assert190 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()191 ->string($childTag->getData())->isEmpty()192 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()193 ->string($otherChildTag->getData())->isEmpty()194 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()195 ->string($littleChildTag->getData())->isEmpty()196 ;197 $template->{$childTag->getTag()} = uniqid();198 $template->{$otherChildTag->getTag()} = uniqid();199 $template->{$littleChildTag->getTag()} = uniqid();200 $this->assert201 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()202 ->string($childTag->getData())->isNotEmpty()203 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()204 ->string($otherChildTag->getData())->isNotEmpty()205 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()206 ->string($littleChildTag->getData())->isNotEmpty()207 ;208 unset($template->{$childTag->getTag()});209 $this->assert210 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()211 ->string($childTag->getData())->isEmpty()212 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()213 ->string($otherChildTag->getData())->isNotEmpty()214 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()215 ->string($littleChildTag->getData())->isNotEmpty()216 ;217 unset($template->{$otherChildTag->getTag()});218 $this->assert219 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()220 ->string($childTag->getData())->isEmpty()221 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()222 ->string($otherChildTag->getData())->isEmpty()223 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()224 ->string($littleChildTag->getData())->isNotEmpty()225 ;226 unset($template->{$littleChildTag->getTag()});227 $this->assert228 ->boolean(isset($template->{$childTag->getTag()}))->isTrue()229 ->string($childTag->getData())->isEmpty()230 ->boolean(isset($template->{$otherChildTag->getTag()}))->isTrue()231 ->string($otherChildTag->getData())->isEmpty()232 ->boolean(isset($template->{$littleChildTag->getTag()}))->isTrue()233 ->string($littleChildTag->getData())->isEmpty()234 ;235 }236 public function testGetRoot()237 {238 $template = new atoum\template();239 $this->assert240 ->object($template->getRoot())->isIdenticalTo($template)241 ;242 $template->addChild($childTemplate = new atoum\template());243 $this->assert244 ->object($template->getRoot())->isIdenticalTo($template)245 ->object($childTemplate->getRoot())->isIdenticalTo($template)246 ;247 $childTemplate->addChild($littleChildTemplate = new atoum\template());248 $this->assert249 ->object($template->getRoot())->isIdenticalTo($template)250 ->object($childTemplate->getRoot())->isIdenticalTo($template)251 ->object($littleChildTemplate->getRoot())->isIdenticalTo($template)252 ;253 }254 public function testGetParent()255 {256 $template = new atoum\template();257 $this->assert258 ->variable($template->getParent())->isNull()259 ;260 $template->addChild($childTemplate = new atoum\template());261 $this->assert262 ->variable($template->getParent())->isNull()263 ->object($childTemplate->getParent())->isIdenticalTo($template)264 ;265 $childTemplate->addChild($littleChildTemplate = new atoum\template());266 $this->assert267 ->variable($template->getParent())->isNull()268 ->object($childTemplate->getParent())->isIdenticalTo($template)269 ->object($littleChildTemplate->getParent())->isIdenticalTo($childTemplate)270 ;271 }272 public function testParentIsSet()273 {274 $template = new atoum\template();275 $this->assert276 ->boolean($template->parentIsSet())->isFalse()277 ;278 $childTemplate = new atoum\template();279 $this->assert280 ->boolean($template->parentIsSet())->isFalse()281 ->boolean($childTemplate->parentIsSet())->isFalse()282 ;283 $template->addChild($childTemplate);284 $this->assert285 ->boolean($template->parentIsSet())->isFalse()286 ->boolean($childTemplate->parentIsSet())->isTrue()287 ;288 $littleChildTemplate = new atoum\template();289 $this->assert290 ->boolean($template->parentIsSet())->isFalse()291 ->boolean($childTemplate->parentIsSet())->isTrue()292 ->boolean($littleChildTemplate->parentIsSet())->isFalse()293 ;294 $childTemplate->addChild($littleChildTemplate);295 $this->assert296 ->boolean($template->parentIsSet())->isFalse()297 ->boolean($childTemplate->parentIsSet())->isTrue()298 ->boolean($littleChildTemplate->parentIsSet())->isTrue()299 ;300 }301 public function testUnsetParent()302 {303 $template = new atoum\template();304 $this->assert305 ->boolean($template->parentIsSet())->isFalse()306 ->object($template->unsetParent())->isIdenticalTo($template)307 ->boolean($template->parentIsSet())->isFalse()308 ;309 $template->addChild($childTemplate = new atoum\template());310 $this->assert311 ->boolean($template->parentIsSet())->isFalse()312 ->boolean($childTemplate->parentIsSet())->isTrue()313 ->object($template->unsetParent())->isIdenticalTo($template)314 ->object($childTemplate->unsetParent())->isIdenticalTo($childTemplate)315 ->boolean($template->parentIsSet())->isFalse()316 ->boolean($childTemplate->parentIsSet())->isFalse()317 ;318 }319 public function testSetParent()320 {321 $childTemplate = new atoum\template();322 $this->assert323 ->boolean($childTemplate->parentIsSet())->isFalse()324 ->object($childTemplate->setParent(new atoum\template()))->isIdenticalTo($childTemplate)325 ->boolean($childTemplate->parentIsSet())->isTrue()326 ;327 }328 public function testGetData()329 {330 $template = new atoum\template();331 $this->assert332 ->string($template->getData())->isEmpty()333 ;334 $template = new atoum\template($data = uniqid());335 $this->assert336 ->string($template->getData())->isEqualTo($data)337 ;338 $template = new atoum\template();339 $template->setData($data = uniqid());340 $this->assert341 ->string($template->getData())->isEqualTo($data)342 ;343 $template->addChild(new atoum\template($otherData = uniqid()));344 $this->assert345 ->string($template->getData())->isEqualTo($data)346 ;347 $template->build();348 $this->assert349 ->string($template->getData())->isEqualTo($data . $otherData)350 ;351 }352 public function testSetData()353 {354 $template = new atoum\template();355 $this->assert356 ->object($template->setData($data = uniqid()))->isIdenticalTo($template)357 ->string($template->getData())->isEqualTo($data)358 ;359 }360 public function testAddData()361 {362 $template = new atoum\template();363 $this->assert364 ->object($template->addData($data = uniqid()))->isIdenticalTo($template)365 ->string($template->getData())->isEqualTo($data)366 ->object($template->addData($data))->isIdenticalTo($template)367 ->string($template->getData())->isEqualTo($data . $data)368 ->object($template->addData($otherData = uniqid()))->isIdenticalTo($template)369 ->string($template->getData())->isEqualTo($data . $data . $otherData)370 ;371 }372 public function testResetData()373 {374 $template = new atoum\template();375 $this->assert376 ->string($template->getData())->isEmpty()377 ->object($template->resetData())->isIdenticalTo($template)378 ->string($template->getData())->isEmpty()379 ;380 $template = new atoum\template($data = uniqid());381 $this->assert382 ->string($template->getData())->isEqualTo($data)383 ->object($template->resetData())->isIdenticalTo($template)384 ->string($template->getData())->isEmpty()385 ;386 }387 public function testGetId()388 {389 $template = new atoum\template();390 $this->assert391 ->variable($template->getId())->isNull()392 ;393 }394 public function testIsRoot()395 {396 $template = new atoum\template();397 $this->assert398 ->boolean($template->isRoot())->isTrue()399 ;400 }401 public function testIsChild()402 {403 $template = new atoum\template();404 $childTemplate = new atoum\template();405 $this->assert406 ->boolean($template->isChild($childTemplate))->isFalse()407 ;408 $template->addChild($childTemplate);409 $this->assert410 ->boolean($template->isChild($childTemplate))->isTrue()411 ;412 }413 public function testGetTag()414 {415 $template = new atoum\template();416 $this->assert417 ->variable($template->getTag())->isNull()418 ;419 }420 public function testGetChildren()421 {422 $template = new atoum\template();423 $this->assert424 ->array($template->getChildren())->isEmpty()425 ;426 $template->addChild($childTemplate = new atoum\template());427 $this->assert428 ->array($template->getChildren())->isIdenticalTo(array($childTemplate))429 ;430 $template->addChild($otherChildTemplate = new atoum\template());431 $this->assert432 ->array($template->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))433 ;434 $childTemplate->addChild($littleChildTemplate = new atoum\template());435 $this->assert436 ->array($template->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))437 ;438 }439 public function testAddChild()440 {441 $template = new atoum\template();442 $this->assert443 ->boolean($template->hasChildren())->isFalse()444 ->object($template->addChild($childTemplate = new atoum\template()))->isIdenticalTo($template)445 ->object($childTemplate->getParent())->isIdenticalTo($template)446 ->array($template->getChildren())->isIdenticalTo(array($childTemplate))447 ->object($template->addChild($childTemplate))->isIdenticalTo($template)448 ->object($childTemplate->getParent())->isIdenticalTo($template)449 ->array($template->getChildren())->isIdenticalTo(array($childTemplate))450 ;451 $otherTemplate = new atoum\template();452 $otherTemplate->addChild($otherChildTemplate = new atoum\template());453 $this->assert454 ->array($otherTemplate->getChildren())->isIdenticalTo(array($otherChildTemplate))455 ->object($otherChildTemplate->getParent())->isIdenticalTo($otherTemplate)456 ->object($template->addChild($otherChildTemplate))->isIdenticalTo($template)457 ->array($otherTemplate->getChildren())->isEmpty()458 ->object($otherChildTemplate->getParent())->isIdenticalTo($template)459 ->array($template->getChildren())->isIdenticalTo(array($childTemplate, $otherChildTemplate))460 ;461 $template = new atoum\template();462 $templateWithId = new atoum\template\tag(uniqid());463 $templateWithId->setId($id = uniqid());464 $templateWithSameId = clone $templateWithId;465 $this->assert466 ->boolean($template->hasChildren())->isFalse()467 ->object($template->addChild($templateWithId))->isIdenticalTo($template)468 ->array($template->getChildren())->isIdenticalTo(array($templateWithId))469 ->object($template->addChild($templateWithId))->isIdenticalTo($template)470 ->array($template->getChildren())->isIdenticalTo(array($templateWithId))471 ->exception(function() use ($template, $templateWithSameId) {472 $template->addChild($templateWithSameId);473 }474 )475 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')476 ->hasMessage('Id \'' . $id . '\' is already defined')477 ;478 }479 public function testDeleteChild()480 {481 $template = new atoum\template();482 $template->addChild($childTemplate = new atoum\template());483 $this->assert484 ->object($childTemplate->getParent())->isIdenticalTo($template)485 ->array($template->getChildren())->isIdenticalTo(array($childTemplate))486 ->object($template->deleteChild($childTemplate))->isIdenticalTo($template)487 ->variable($childTemplate->getParent())->isNull()488 ->array($template->getChildren())->isEmpty()489 ;490 }491 public function testHasChildren()492 {493 $template = new atoum\template();494 $this->assert495 ->boolean($template->hasChildren())->isFalse()496 ;497 $template->addChild($childTemplate = new atoum\template());498 $this->assert499 ->boolean($template->hasChildren())->isTrue()500 ;501 $template->deleteChild($childTemplate);502 $this->assert503 ->boolean($template->hasChildren())->isFalse()504 ;505 }506 public function testGetByTag()507 {508 $template = new atoum\template();509 $this->assert510 ->object($iterator = $template->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')511 ->sizeOf($iterator)->isZero()512 ;513 $template->addChild($tag = new atoum\template\tag(uniqid()));514 $this->assert515 ->object($iterator = $template->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')516 ->sizeOf($iterator)->isZero()517 ->object($iterator = $template->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')518 ->sizeOf($iterator)->isEqualTo(1)519 ->object($iterator->current())->isIdenticalTo($tag)520 ;521 $template->addChild($otherTag = new atoum\template\tag($tag->getTag()));522 $this->assert523 ->object($iterator = $template->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')524 ->sizeOf($iterator)->isZero()525 ->object($iterator = $template->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')526 ->sizeOf($iterator)->isEqualTo(2)527 ->object($iterator->current())->isIdenticalTo($tag)528 ->object($iterator->next()->current())->isIdenticalTo($otherTag)529 ;530 $tag->addChild($childTag = new atoum\template\tag($tag->getTag()));531 $this->assert532 ->object($iterator = $template->getByTag(uniqid()))->isInstanceOf('mageekguy\atoum\template\iterator')533 ->sizeOf($iterator)->isZero()534 ->object($iterator = $template->getByTag($tag->getTag()))->isInstanceOf('mageekguy\atoum\template\iterator')535 ->sizeOf($iterator)->isEqualTo(3)536 ->object($iterator->current())->isIdenticalTo($tag)537 ->object($iterator->next()->current())->isIdenticalTo($childTag)538 ->object($iterator->next()->current())->isIdenticalTo($otherTag)539 ;540 }541 public function testGetById()542 {543 $template = new atoum\template();544 $this->assert545 ->variable($template->getById(uniqid()))->isNull()546 ;547 $tag = new atoum\template\tag(uniqid());548 $template->addChild($tag->setId($id = uniqid()));549 $this->assert550 ->variable($template->getById(uniqid()))->isNull()551 ->object($template->getById($id))->isIdenticalTo($tag)552 ;553 $childTag = new atoum\template\tag(uniqid());554 $tag->addChild($childTag->setId($childId = uniqid()));555 $this->assert556 ->variable($template->getById(uniqid()))->isNull()557 ->object($template->getById($id))->isIdenticalTo($tag)558 ->object($tag->getById($id))->isIdenticalTo($tag)559 ->object($template->getById($childId))->isIdenticalTo($childTag)560 ->object($tag->getById($childId))->isIdenticalTo($childTag)561 ->object($childTag->getById($childId))->isIdenticalTo($childTag)562 ->variable($childTag->getById($id, false))->isNull()563 ;564 }565 public function testBuild()566 {567 $template = new atoum\template();568 $this->assert569 ->string($template->getData())->isEmpty()570 ->boolean($template->hasChildren())->isFalse()571 ->object($template->build())->isIdenticalTo($template)572 ->string($template->getData())->isEmpty()573 ;574 $template = new atoum\template($data = uniqid());575 $this->assert576 ->string($template->getData())->isEqualTo($data)577 ->boolean($template->hasChildren())->isFalse()578 ->object($template->build())->isIdenticalTo($template)579 ->string($template->getData())->isEqualTo($data)580 ->object($template->build())->isIdenticalTo($template)581 ->string($template->getData())->isEqualTo($data)582 ;583 $template->addChild($childTemplate = new atoum\template($childData = uniqid()));584 $this->assert585 ->string($template->getData())->isEqualTo($data)586 ->string($childTemplate->getData())->isEqualTo($childData)587 ->array($template->getChildren())->isIdenticalTo(array($childTemplate))588 ->object($template->build())->isIdenticalTo($template)589 ->string($template->getData())->isEqualTo($data . $childData)590 ->string($childTemplate->getData())->isEqualTo($childData)591 ->object($template->build())->isIdenticalTo($template)592 ->string($template->getData())->isEqualTo($data . $childData . $childData)593 ;594 }595 public function testGetChild()596 {597 $template = new atoum\template();598 $this->assert599 ->variable($template->getChild(0))->isNull()600 ->variable($template->getChild(rand(1, PHP_INT_MAX)))->isNull()601 ->variable($template->getChild(- rand(1, PHP_INT_MAX)))->isNull()602 ;603 $template->addChild($childTemplate = new atoum\template());604 $this->assert605 ->variable($template->getChild(0))->isIdenticalTo($childTemplate)606 ->variable($template->getChild(rand(1, PHP_INT_MAX)))->isNull()607 ->variable($template->getChild(- rand(1, PHP_INT_MAX)))->isNull()608 ;609 }610}...

Full Screen

Full Screen

TreeNode.php

Source:TreeNode.php Github

copy

Full Screen

...131 ->isEqualTo(2)132 ->array($node->getChildren())133 ->isEqualTo($children)134 ->object($node->getParent())135 ->isIdenticalTo($parent);136 }137 public function case_set_id()138 {139 $this140 ->given($node = new SUT('foo'))141 ->when($result = $node->setId('bar'))142 ->then143 ->string($result)144 ->isEqualTo('foo');145 }146 public function case_get_id()147 {148 $this149 ->given(150 $node = new SUT('foo'),151 $node->setId('bar')152 )153 ->when($result = $node->getId())154 ->then155 ->string($result)156 ->isEqualTo('bar');157 }158 public function case_set_value()159 {160 $this161 ->given($node = new SUT('foo', ['bar']))162 ->when($result = $node->setValue(['baz']))163 ->then164 ->array($result)165 ->isEqualTo(['bar']);166 }167 public function case_get_value()168 {169 $this170 ->given(171 $node = new SUT('foo', ['bar']),172 $node->setValue(['baz'])173 )174 ->when($result = $node->getValue())175 ->then176 ->array($result)177 ->isEqualTo(['baz']);178 }179 public function case_get_value_token()180 {181 $this182 ->given($node = new SUT('foo', ['token' => 'bar']))183 ->when($result = $node->getValueToken())184 ->then185 ->string($result)186 ->isEqualTo('bar');187 }188 public function case_get_value_token_undefined()189 {190 $this191 ->given($node = new SUT('foo', ['bar']))192 ->when($result = $node->getValueToken())193 ->then194 ->variable($result)195 ->isNull();196 }197 public function case_get_value_value()198 {199 $this200 ->given($node = new SUT('foo', ['value' => 'bar']))201 ->when($result = $node->getValueValue())202 ->then203 ->string($result)204 ->isEqualTo('bar');205 }206 public function case_get_value_value_undefined()207 {208 $this209 ->given($node = new SUT('foo', ['bar']))210 ->when($result = $node->getValueValue())211 ->then212 ->variable($result)213 ->isNull();214 }215 public function case_is_token()216 {217 $this218 ->given($node = new SUT('foo', ['bar']))219 ->when($result = $node->isToken())220 ->then221 ->boolean($result)222 ->isTrue();223 }224 public function case_is_not_token()225 {226 $this227 ->given($node = new SUT('foo'))228 ->when($result = $node->isToken())229 ->then230 ->boolean($result)231 ->isFalse();232 }233 public function case_prepend_child()234 {235 $this236 ->given(237 $childA = new SUT('baz'),238 $childB = new SUT('qux'),239 $node = new SUT('foo', ['bar'], [$childA])240 )241 ->when($result = $node->prependChild($childB))242 ->then243 ->object($result)244 ->isIdenticalTo($node)245 ->integer($result->getChildrenNumber())246 ->isEqualTo(2)247 ->array($result->getChildren())248 ->isEqualTo([$childB, $childA]);249 }250 public function case_append_child()251 {252 $this253 ->given(254 $childA = new SUT('baz'),255 $childB = new SUT('qux'),256 $node = new SUT('foo', ['bar'], [$childA])257 )258 ->when($result = $node->appendChild($childB))259 ->then260 ->object($result)261 ->isIdenticalTo($node)262 ->integer($result->getChildrenNumber())263 ->isEqualTo(2)264 ->array($result->getChildren())265 ->isEqualTo([$childA, $childB]);266 }267 public function case_set_children()268 {269 $this270 ->given(271 $childA = new SUT('baz'),272 $childB = new SUT('qux'),273 $childC = new SUT('hello'),274 $node = new SUT('foo', ['bar'], [$childA])275 )276 ->when($result = $node->setChildren([$childB, $childC]))277 ->then278 ->array($result)279 ->isEqualTo([$childA])280 ->integer($node->getChildrenNumber())281 ->isEqualTo(2)282 ->array($node->getChildren())283 ->isEqualTo([$childB, $childC]);284 }285 public function case_get_child()286 {287 $this288 ->given(289 $childA = new SUT('baz'),290 $childB = new SUT('qux'),291 $node = new SUT('foo', ['bar'], [$childA, $childB])292 )293 ->when($result = $node->getChild(0))294 ->then295 ->object($result)296 ->isIdenticalTo($childA)297 ->when($result = $node->getChild(1))298 ->then299 ->object($result)300 ->isIdenticalTo($childB);301 }302 public function case_get_child_undefined()303 {304 $this305 ->given(306 $node = new SUT('foo', ['bar'])307 )308 ->when($result = $node->getChild(0))309 ->then310 ->variable($result)311 ->isNull();312 }313 public function case_get_children()314 {315 $this316 ->given(317 $childA = new SUT('baz'),318 $childB = new SUT('qux'),319 $node = new SUT('foo', ['bar'], [$childA, $childB])320 )321 ->when($result = $node->getChildren())322 ->then323 ->array($result)324 ->isEqualTo([$childA, $childB]);325 }326 public function case_get_children_number()327 {328 $this329 ->given(330 $childA = new SUT('baz'),331 $childB = new SUT('qux'),332 $node = new SUT('foo', ['bar'])333 )334 ->when($result = $node->getChildrenNumber())335 ->then336 ->integer($result)337 ->isEqualTo(0)338 ->when(339 $node->setChildren([$childA, $childB]),340 $result = $node->getChildrenNumber()341 )342 ->then343 ->integer($result)344 ->isEqualTo(2);345 }346 public function case_child_exists()347 {348 $this349 ->given($node = new SUT('foo', ['bar'], [new SUT('baz')]))350 ->when($result = $node->childExists(0))351 ->then352 ->boolean($result)353 ->isTrue();354 }355 public function case_child_does_not_exist()356 {357 $this358 ->given($node = new SUT('foo', ['bar']))359 ->when($result = $node->childExists(0))360 ->then361 ->boolean($result)362 ->isFalse();363 }364 public function case_set_parent()365 {366 $this367 ->given(368 $parent = new SUT('baz'),369 $node = new SUT('foo', ['bar'], [], $parent)370 )371 ->when($result = $node->setParent(new SUT('qux')))372 ->then373 ->object($result)374 ->isIdenticalTo($parent);375 }376 public function case_get_parent()377 {378 $this379 ->given(380 $parent = new SUT('qux'),381 $node = new SUT('foo', ['bar'], [], new SUT('baz')),382 $node->setParent($parent)383 )384 ->when($result = $node->getParent())385 ->then386 ->object($result)387 ->isIdenticalTo($parent);388 }389 public function case_get_data()390 {391 $this392 ->given($node = new SUT('foo'))393 ->when($result = $node->getData())394 ->then395 ->array($result)396 ->isEmpty()397 ->when(398 $result[] = 'bar',399 $result[] = 'baz',400 $result = $node->getData()401 )...

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new child();2$obj->isIdenticalTo($obj);3$obj = new child();4$obj->isIdenticalTo($obj);5$obj = new child();6$obj->isIdenticalTo($obj);7$obj = new child();8$obj->isIdenticalTo($obj);9$obj = new child();10$obj->isIdenticalTo($obj);11$obj = new child();12$obj->isIdenticalTo($obj);13$obj = new child();14$obj->isIdenticalTo($obj);15$obj = new child();16$obj->isIdenticalTo($obj);17$obj = new child();18$obj->isIdenticalTo($obj);19$obj = new child();20$obj->isIdenticalTo($obj);21$obj = new child();22$obj->isIdenticalTo($obj);23$obj = new child();24$obj->isIdenticalTo($obj);25$obj = new child();26$obj->isIdenticalTo($obj);27$obj = new child();28$obj->isIdenticalTo($obj);29$obj = new child();30$obj->isIdenticalTo($obj);

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new ChildClass();2$obj->isIdenticalTo($obj);3$obj = new ParentClass();4$obj->isIdenticalTo($obj);5Fatal error: Call to undefined method ParentClass::isIdenticalTo() in /2.php on line 36$obj = new ChildClass();7$obj->isIdenticalTo($obj);8$obj = new ParentClass();9$obj->isIdenticalTo($obj);10$obj = new ParentClass();11$obj->isIdenticalTo($obj);

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new child();2$obj->isIdenticalTo($obj);3$obj = new child();4$obj->isIdenticalTo($obj);5$obj = new parent();6$obj->isIdenticalTo($obj);

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new ChildClass();2$obj->isIdenticalTo($obj1);3$obj = new ChildClass();4$obj->isIdenticalTo($obj1);5$obj = new ChildClass();6$obj->isIdenticalTo($obj1);7$obj = new ChildClass();8$obj->isIdenticalTo($obj1);9$obj = new ChildClass();10$obj->isIdenticalTo($obj1);11$obj = new ChildClass();12$obj->isIdenticalTo($obj1);13$obj = new ChildClass();14$obj->isIdenticalTo($obj1);15$obj = new ChildClass();16$obj->isIdenticalTo($obj1);17$obj = new ChildClass();18$obj->isIdenticalTo($obj1);19$obj = new ChildClass();20$obj->isIdenticalTo($obj1);21$obj = new ChildClass();22$obj->isIdenticalTo($obj1);23$obj = new ChildClass();24$obj->isIdenticalTo($obj1);25$obj = new ChildClass();26$obj->isIdenticalTo($obj1);27$obj = new ChildClass();28$obj->isIdenticalTo($obj1);

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$child = new ChildClass();2$child->isIdenticalTo($child);3$parent = new ParentClass();4$parent->isIdenticalTo($parent);5$grandParent = new GrandParentClass();6$grandParent->isIdenticalTo($grandParent);7$greatGrandParent = new GreatGrandParentClass();8$greatGrandParent->isIdenticalTo($greatGrandParent);9$greatGreatGrandParent = new GreatGreatGrandParentClass();10$greatGreatGrandParent->isIdenticalTo($greatGreatGrandParent);11$greatGreatGreatGrandParent = new GreatGreatGreatGrandParentClass();12$greatGreatGreatGrandParent->isIdenticalTo($greatGreatGreatGrandParent);13$greatGreatGreatGreatGrandParent = new GreatGreatGreatGreatGrandParentClass();14$greatGreatGreatGreatGrandParent->isIdenticalTo($greatGreatGreatGreatGrandParent);15$greatGreatGreatGreatGreatGrandParent = new GreatGreatGreatGreatGreatGrandParentClass();16$greatGreatGreatGreatGreatGrandParent->isIdenticalTo($greatGreatGreatGreatGreatGrandParent);17$greatGreatGreatGreatGreatGreatGrandParent = new GreatGreatGreatGreatGreatGreatGrandParentClass();18$greatGreatGreatGreatGreatGreatGrandParent->isIdenticalTo($greatGreatGreatGreatGreatGreatGrandParent);19$greatGreatGreatGreatGreatGreatGreatGrandParent = new GreatGreatGreatGreatGreatGreatGreatGrandParentClass();20$greatGreatGreatGreatGreatGreatGreatGrandParent->isIdenticalTo($greatGreatGreatGreatGreatGreatGreatGrandParent);

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new child();2$obj->isIdenticalTo();3$obj = new child();4$obj->isIdenticalTo();5$obj = new child();6$obj->isIdenticalTo();7$obj = new child();8$obj->isIdenticalTo();9$obj = new child();10$obj->isIdenticalTo();11$obj = new child();12$obj->isIdenticalTo();13$obj = new child();14$obj->isIdenticalTo();15$obj = new child();16$obj->isIdenticalTo();17$obj = new child();18$obj->isIdenticalTo();19$obj = new child();20$obj->isIdenticalTo();21$obj = new child();

Full Screen

Full Screen

isIdenticalTo

Using AI Code Generation

copy

Full Screen

1$obj = new ChildClass;2echo $obj->isIdenticalTo($obj);3$obj = new ChildClass;4echo $obj->isIdenticalTo($obj);5$obj = new ChildClass;6echo $obj->isIdenticalTo($obj);7$obj = new ChildClass;8echo $obj->isIdenticalTo($obj);9$obj = new ChildClass;10echo $obj->isIdenticalTo($obj);11$obj = new ChildClass;12echo $obj->isIdenticalTo($obj);13$obj = new ChildClass;14echo $obj->isIdenticalTo($obj);15$obj = new ChildClass;16echo $obj->isIdenticalTo($obj);

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger isIdenticalTo code on LambdaTest Cloud Grid

Execute automation tests with isIdenticalTo on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful