dox Executable Documentation

Parse node

Text node

$this->when->iParse('Hello World');
$this->then->theResultShouldBe('[
            { "text":"Hello World" }
        ]');

Closed element

$this->when->iParse('<closed/>');
$this->then->theResultShouldBe('[
            { "element":"closed" }
        ]');

Empty element

$this->when->iParse('<empty></empty>');
$this->then->theResultShouldBe('[
            { "element":"empty" }
        ]');

Empty and closed

$this->when->iParse('<one></one><two/>');
$this->then->theResultShouldBe('[
            { "element":"one" },
            { "element":"two" }
        ]');

Unclosed element

$this->when->iTryToParse('<unclosed>');
$this->then->theResultShouldBe('[
            { "element":"unclosed" }
        ]');

Unmatched

$this->when->iTryToParse('<one></two>');
$this->then->anExceptionShouldBeThrownContaining('one');

Mal formed

$this->when->iParse('<one<two/>/>');
$this->then->theResultShouldBe('[
            { "text":"<one" },
            { "element":"two" },
            { "text":"/>" }
        ]');

Mal formed with space

$this->when->iParse('<one <two/>/>');
$this->then->theResultShouldBe('[
            { "text":"<one " },
            { "element":"two" },
            { "text":"/>" }
        ]');

Starts with space

$this->when->iParse('< div/>');
$this->then->theResultShouldBe('[
            { "text":"< div/>" }
        ]');

Starts with none letter

$this->when->iParse('<!not an element>');
$this->then->theResultShouldBe('[
            { "text":"<!not an element>" }
        ]');

Case sensitive

$this->when->iParse('<Element></Element>');
$this->then->theResultShouldBe('[
            { "element":"Element" }
        ]');