40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
namespace nur\sery\php\content;
|
|
|
|
use nur\sery\php\content\content;
|
|
use nur\sery\php\content\impl\html;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class contentTest extends TestCase {
|
|
function testFlattern() {
|
|
self::assertSame([], content::flatten(null));
|
|
self::assertSame([], content::flatten([null]));
|
|
self::assertSame([""], content::flatten(""));
|
|
self::assertSame([""], content::flatten([""]));
|
|
|
|
self::assertSame(["a", "b", "c", "d"], content::flatten(["a", ["b", ["c"], "d"]]));
|
|
}
|
|
|
|
function testResolve_static() {
|
|
self::assertSame([], content::resolve_static(null, null));
|
|
self::assertSame([], content::resolve_static([null], [null]));
|
|
self::assertSame([""], content::resolve_static("", ""));
|
|
self::assertSame([""], content::resolve_static([""], [""]));
|
|
|
|
self::assertSame(["<quoted>"], content::resolve_static("<quoted>", "<quoted>"));
|
|
self::assertSame(["<non-quoted>"], content::resolve_static(["<non-quoted>"], ["<non-quoted>"]));
|
|
|
|
self::assertSame(
|
|
"<h1>title<q/></h1><p>hello<nq/><span>brave<q/></span><span>world<nq/></span></p>",
|
|
content::to_string([
|
|
[html::H1, "title<q/>"],
|
|
[html::P, [
|
|
"hello<nq/>",
|
|
[html::SPAN, "brave<q/>"],
|
|
[html::SPAN, ["world<nq/>"]],
|
|
]],
|
|
]));
|
|
}
|
|
}
|
|
|