nur-sery/tests/php/content/contentTest.php

41 lines
1.4 KiB
PHP
Raw Normal View History

2023-12-30 18:40:23 +04:00
<?php
2023-12-31 18:54:10 +04:00
namespace nur\sery\php\content;
2023-12-30 18:40:23 +04:00
2023-12-31 18:54:10 +04:00
use nur\sery\php\content\impl\html;
2024-06-23 21:58:54 +04:00
use nur\sery\wip\web\content\v;
2023-12-30 18:40:23 +04:00
use PHPUnit\Framework\TestCase;
class contentTest extends TestCase {
2024-06-23 15:07:50 +04:00
function testTo_string() {
self::assertSame("", c::to_string(null));
self::assertSame("", c::to_string(false));
self::assertSame("pouet&lt;q/&gt;", c::to_string("pouet<q/>"));
self::assertSame("pouet<q/>", c::to_string(["pouet<q/>"]));
self::assertSame("hello world", c::to_string(["hello", "world"]));
self::assertSame("hello1 world", c::to_string(["hello1", "world"]));
self::assertSame("hello<world>", c::to_string(["hello", "<world>"]));
self::assertSame("<hello>world", c::to_string(["<hello>", "world"]));
self::assertSame("hello,world", c::to_string(["hello,", "world"]));
self::assertSame("hello&nbsp;world", c::to_string(["hello&nbsp;", "world"]));
self::assertSame("hello. world", c::to_string(["hello.", "world"]));
self::assertSame("hello.<world>", c::to_string(["hello.", "<world>"]));
2023-12-30 18:40:23 +04:00
self::assertSame(
"<h1>title&lt;q/&gt;</h1><p>hello<nq/><span>brave&lt;q/&gt;</span><span>world<nq/></span></p>",
2024-06-23 15:07:50 +04:00
c::to_string([
2023-12-30 18:40:23 +04:00
[html::H1, "title<q/>"],
[html::P, [
"hello<nq/>",
[html::SPAN, "brave<q/>"],
[html::SPAN, ["world<nq/>"]],
]],
]));
}
2024-06-23 21:58:54 +04:00
function testXxx() {
$content = [[v::h1, "hello"]];
self::assertSame("<h1>hello</h1>", c::to_string($content));
}
2023-12-30 18:40:23 +04:00
}