Html.construct.phpt 996 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Html::__construct()
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Html;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. Assert::same('<a lang="cs" href="#" title="" selected>click</a>', (string) Html::el('a lang=cs href="#" title="" selected')->setText('click'));
  10. Assert::same('<a lang="hello" world href="hello world" title="hello \'world">click</a>', (string) Html::el('a lang=hello world href="hello world" title="hello \'world"')->setText('click'));
  11. Assert::same('<a lang=\'hello" world\' href="hello " world title="0">click</a>', (string) Html::el('a lang=\'hello" world\' href="hello "world" title=0')->setText('click'));
  12. Assert::type(Html::class, Html::fromHtml('xxx'));
  13. Assert::same('<a href="#">hello&quot;</a>', (string) Html::fromHtml('<a href="#">hello&quot;</a>'));
  14. Assert::type(Html::class, Html::fromText('xxx'));
  15. Assert::same('&lt;a href="#"&gt;hello&amp;quot;&lt;/a&gt;', (string) Html::fromText('<a href="#">hello&quot;</a>'));