Skip to content

Commit

Permalink
Tests: added test for Html::children && Html::__clone
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x authored and dg committed Mar 26, 2020
1 parent 65b1167 commit e3dd185
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/Utils/Html.children.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,33 @@ test(function () { // ==> Iterator:
Assert::same('optgroup', $el[0]->getName());
Assert::same('option', $el[1]->getName());
});


test(function () { // counting
$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('<ul></ul>', (string) $el);
});


test(function () { // cloning
$el = Html::el('ul');
$el->addHtml(Html::el('li'));

$el2 = clone $el;

Assert::same((string) $el, (string) $el2);
});

0 comments on commit e3dd185

Please sign in to comment.