45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
namespace nulib\php\content;
|
|
|
|
use nulib\php\content\impl\AContent;
|
|
use nulib\php\content\impl\APrintable;
|
|
use nulib\tests\TestCase;
|
|
use nulib\web\content\v;
|
|
|
|
class cTest extends TestCase {
|
|
function testTo_string() {
|
|
self::assertSame("", c::to_string(null));
|
|
self::assertSame("", c::to_string(false));
|
|
self::assertSame("pouet<q/>", 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 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(<<<EOT
|
|
<h1>title<q/></h1>
|
|
<p>hello<nq/><span>brave<q/></span><span>world<nq/></span></p>
|
|
EOT, c::to_string([
|
|
[v::H1, "title<q/>"],
|
|
[v::P, [
|
|
"hello<nq/>",
|
|
[v::SPAN, "brave<q/>"],
|
|
[v::SPAN, ["world<nq/>"]],
|
|
]],
|
|
]));
|
|
|
|
self::assertSame(<<<EOT
|
|
<span>content</span><p>printable</p>
|
|
EOT, c::to_string([
|
|
new AContent(),
|
|
new APrintable(),
|
|
]));
|
|
}
|
|
}
|
|
|