create('li')->setText('one'); $el->addHtml(Html::el('li')->setText('two'))->class('hello'); Assert::same('
two
'); $el->addHtml('three
'); Assert::same('one
<p>two</p>three
', (string) $el); // ==> Get child: Assert::true(isset($el[0])); Assert::same('one
', (string) $el[0]); Assert::same('<p>two</p>', (string) $el[1]); Assert::same('three
', (string) $el[2]); Assert::false(isset($el[3])); }); test('Iterator', function () { $el = Html::el('select'); $el->create('optgroup')->label('Main')->create('option')->setText('sub one')->create('option')->setText('sub two'); $el->create('option')->setText('Item'); Assert::same('', (string) $el); Assert::same(2, count($el)); Assert::same('optgroup', $el[0]->getName()); Assert::same('option', $el[1]->getName()); }); test('counting', function () { $el = Html::el('ul'); $el->addHtml('li'); $el->addHtml('li'); Assert::count(2, $el); Assert::count(2, $el->getChildren()); Assert::count(2, iterator_to_array($el->getIterator())); unset($el[1]); Assert::count(1, $el->getChildren()); $el->removeChildren(); Assert::count(0, $el->getChildren()); Assert::count(0, iterator_to_array($el->getIterator())); Assert::same('