<?php
namespace nulib\php\content;

use nulib\php\content\impl\html;
use nulib\web\content\v;
use PHPUnit\Framework\TestCase;

class cTest extends TestCase {
  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>"]));

    self::assertSame(
      "<h1>title&lt;q/&gt;</h1><p>hello<nq/><span>brave&lt;q/&gt;</span><span>world<nq/></span></p>",
      c::to_string([
        [html::H1, "title<q/>"],
        [html::P, [
          "hello<nq/>",
          [html::SPAN, "brave<q/>"],
          [html::SPAN, ["world<nq/>"]],
        ]],
      ]));
  }

  function testXxx() {
    $content = [[v::h1, "hello"]];
    self::assertSame("<h1>hello</h1>", c::to_string($content));
  }
}

