public function testCheckString() { $this->define->parserException = '\\mageekguy\\atoum\\tests\\units\\asserters\\template\\parser\\exception'; $this->if($parser = new template\parser())->then->object($parser->checkString(uniqid()))->isIdenticalTo($parser)->object($parser->checkString('<' . uniqid() . ':' . uniqid() . ' />'))->isIdenticalTo($parser)->if($tag = uniqid())->then->object($parser->checkString('<'))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':'))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . '/>'))->isIdenticalTo($parser)->parserException(function () use($parser, $tag) { $parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . ' id="" />'); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Id must not be empty')->hasErrorLine(1)->hasErrorOffset(1)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . ' id="' . uniqid() . '" />'))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . '></' . template\parser::defaultNamespace . ':' . $tag . '>'))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . ' ' . "\t" . ' ></' . template\parser::defaultNamespace . ':' . $tag . '>'))->isIdenticalTo($parser)->object($parser->checkString('<' . template\parser::defaultNamespace . ':' . $tag . '></' . template\parser::defaultNamespace . ':' . $tag . ' ' . "\t" . ' >'))->isIdenticalTo($parser)->if($tagWithId = '<' . template\parser::defaultNamespace . ':' . $tag . ' id="' . ($id = uniqid()) . '" />')->then->parserException(function () use($parser, $tagWithId) { $parser->checkString($tagWithId . $tagWithId); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Id \'' . $id . '\' is already defined in line 1 at offset 1')->hasErrorLine(1)->hasErrorOffset(41)->if($tagWithInvalidAttribute = '<' . template\parser::defaultNamespace . ':' . $tag . ' foo="bar" />')->then->parserException(function () use($parser, $tagWithInvalidAttribute) { $parser->checkString($tagWithInvalidAttribute); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Attribute \'foo\' is unknown')->hasErrorLine(1)->hasErrorOffset(1)->if($firstTag = '<' . template\parser::defaultNamespace . ':' . $tag . '>')->then->parserException(function () use($parser, $firstTag) { $parser->checkString($firstTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $tag . '\' must be closed')->hasErrorLine(1)->hasErrorOffset(strlen($firstTag) + 1)->if($firstTag = '<' . template\parser::defaultNamespace . ':' . $tag . '>')->and($eols = str_repeat("\n", rand(1, 10)))->then->parserException(function () use($parser, $firstTag, $eols) { $parser->checkString($eols . $firstTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $tag . '\' must be closed')->hasErrorLine(strlen($eols) + 1)->hasErrorOffset(strlen($firstTag) + 1)->if($spaces = str_repeat(' ', rand(1, 10)))->then->parserException(function () use($parser, $firstTag, $eols, $spaces) { $parser->checkString($eols . $spaces . $firstTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $tag . '\' must be closed')->hasErrorLine(strlen($eols) + 1)->hasErrorOffset(strlen($firstTag) + strlen($spaces) + 1)->if($firstTag = '<' . template\parser::defaultNamespace . ':' . $tag . '>')->and($secondTag = '</' . template\parser::defaultNamespace . ':' . ($notOpenTag = uniqid()) . ' ' . "\t" . ' >')->then->parserException(function () use($parser, $firstTag, $secondTag) { $parser->checkString($firstTag . $secondTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $notOpenTag . '\' is not open')->hasErrorLine(1)->hasErrorOffset(strlen($firstTag) + 1)->parserException(function () use($parser, $firstTag, $secondTag, $eols) { $parser->checkString($eols . $firstTag . $secondTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $notOpenTag . '\' is not open')->hasErrorLine(strlen($eols) + 1)->hasErrorOffset(strlen($firstTag) + 1)->parserException(function () use($parser, $firstTag, $secondTag, $eols, $spaces) { $parser->checkString($eols . $spaces . $firstTag . $secondTag); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->isInstanceOf('mageekguy\\atoum\\template\\parser\\exception')->hasMessage('Tag \'' . $notOpenTag . '\' is not open')->hasErrorLine(strlen($eols) + 1)->hasErrorOffset(strlen($firstTag) + strlen($spaces) + 1); }