예제 #1
0
 function testDoesNotRenderChildrenOnceLimitIsReached()
 {
     $wiki = new T_Text_Plain('some content');
     $wiki->addChild(new T_Text_Paragraph('child1'));
     $wiki->addChild(new T_Text_Header(3, 'child2'));
     $wiki->addChild(new T_Text_InternalLink('child3', '/some/path'));
     $wiki->addChild(new T_Text_InternalLink('child4', 'url'));
     $short = new T_Text_Plain('some ...');
     $test = new T_Xhtml_TextPreview(10, $this->getRootUrl());
     $ref = new T_Xhtml_Text($this->getRootUrl());
     $this->assertSame($this->getVisitorRender($short, $ref), $this->getVisitorRender($wiki, $test));
 }
예제 #2
0
 function testEmphTextParsedInChildElement()
 {
     $expected = new T_Text_Plain('parent');
     $expected->addChild(new T_Text_Plain(), 'nest');
     $expected->nest->addChild(new T_Text_Emph('content'));
     $element = new T_Text_Plain('parent');
     $element->addChild(new T_Text_Plain('**content**'), 'nest');
     $element->accept(new T_Text_EmphLexer());
     $this->assertEquals($expected, $element);
 }
예제 #3
0
 function testMultiByteTextWithPriorPostAndMiddleContent()
 {
     $text = 'Iñtër^{nâtiôn}àlizætiøn_{Iñtër}nâtiônàlizætiøn';
     $element = new T_Text_Plain($text);
     $element->accept(new T_Text_SuperSubscriptLexer());
     $expected = new T_Text_Plain();
     $expected->addChild(new T_Text_Plain('Iñtër'));
     $expected->addChild(new T_Text_Superscript('nâtiôn'));
     $expected->addChild(new T_Text_Plain('àlizætiøn'));
     $expected->addChild(new T_Text_Subscript('Iñtër'));
     $expected->addChild(new T_Text_Plain('nâtiônàlizætiøn'));
     $this->assertEquals($expected, $element);
 }
예제 #4
0
 function testMultiByteTextWithPriorPostAndMiddleContent()
 {
     $text = "Iñtër\n----\nàlizætiøn\n----\nnâtiônàlizætiøn";
     $element = new T_Text_Plain($text);
     $element->accept(new T_Text_DividerLexer());
     $expected = new T_Text_Plain();
     $expected->addChild(new T_Text_Plain('Iñtër'));
     $expected->addChild(new T_Text_Divider());
     $expected->addChild(new T_Text_Plain('àlizætiøn'));
     $expected->addChild(new T_Text_Divider());
     $expected->addChild(new T_Text_Plain('nâtiônàlizætiøn'));
     $this->assertEquals($expected, $element);
 }
예제 #5
0
 function testLinksParsedInChildElement()
 {
     $expected = new T_Text_Plain('parent');
     $expected->addChild(new T_Text_Plain(), 'nest');
     $expected->nest->addChild(new T_Text_ExternalLink('content', 'http://example.com'));
     $element = new T_Text_Plain('parent');
     $element->addChild(new T_Text_Plain('[http://example.com content]'), 'nest');
     $element->accept(new T_Text_LinkLexer());
     $this->assertEquals($expected, $element);
 }
예제 #6
0
    function testParsesARepeatedlyNestedList()
    {
        $type1 = T_Text_List::ORDERED;
        $type2 = T_Text_List::UNORDERED;
        $content = <<<CONTENT
          {$type1} Item #1
            {$type2} Item #2
            {$type2} Item #3
          {$type1} Item #4
          {$type1} Item #5
            {$type2} Item #6
            {$type2} Item #7
          {$type1} Item #8
CONTENT;
        $text = new T_Text_Plain($content);
        $expect = new T_Text_Plain();
        $expect->addChild($list = new T_Text_List($type1));
        $list->addChild($item = new T_Text_ListItem('Item #1'));
        $item->addChild($nest = new T_Text_List($type2));
        $nest->addChild(new T_Text_ListItem('Item #2'));
        $nest->addChild(new T_Text_ListItem('Item #3'));
        $list->addChild(new T_Text_ListItem('Item #4'));
        $list->addChild($item2 = new T_Text_ListItem('Item #5'));
        $item2->addChild($nest2 = new T_Text_List($type2));
        $nest2->addChild(new T_Text_ListItem('Item #6'));
        $nest2->addChild(new T_Text_ListItem('Item #7'));
        $list->addChild(new T_Text_ListItem('Item #8'));
        $text->accept(new T_Text_ListLexer());
        $this->assertEquals($expect, $text);
    }
예제 #7
0
 function testWindowsLineFeedIsRecognised()
 {
     $element = new T_Text_Plain('pre' . "\r\n" . '== header ==' . "\r\n" . 'post');
     $element->accept(new T_Text_HeaderLexer());
     $expected = new T_Text_Plain();
     $expected->addChild(new T_Text_Plain('pre'));
     $expected->addChild(new T_Text_Header(1, 'header'));
     $expected->addChild(new T_Text_Plain('post'));
     $this->assertEquals($expected, $element);
 }
예제 #8
0
 function testParsesMultipleTablesInOneBlockWithPriorAndPostContent()
 {
     $text = new T_Text_Plain("Iñtërnât\n| lizætiøn | Iñtër |\niônàl\n| ætiøn | Iñt |\nizætiøn");
     $expect = new T_Text_Plain();
     $expect->addChild(new T_Text_Plain('Iñtërnât'));
     $expect->addChild($table = new T_Text_Table());
     $table->addChild($row = new T_Text_TableRow());
     $row->addChild(new T_Text_TableCell('lizætiøn'))->addChild(new T_Text_TableCell('Iñtër'));
     $expect->addChild(new T_Text_Plain('iônàl'));
     $expect->addChild($table = new T_Text_Table());
     $table->addChild($row = new T_Text_TableRow());
     $row->addChild(new T_Text_TableCell('ætiøn'))->addChild(new T_Text_TableCell('Iñt'));
     $expect->addChild(new T_Text_Plain('izætiøn'));
     $text->accept(new T_Text_TableLexer());
     $this->assertEquals($expect, $text);
 }
예제 #9
0
 function testParagraphsParsedInChildElement()
 {
     $expected = new T_Text_Plain();
     $expected->addChild(new T_Text_Plain(), 'nest');
     $expected->addChild(new T_Text_Paragraph('para1'))->addChild(new T_Text_Paragraph('para2'));
     $expected->nest->addChild(new T_Text_Paragraph('nested1'))->addChild(new T_Text_Paragraph('nested2'));
     $element = new T_Text_Plain("para1\n\n\npara2");
     $element->addChild(new T_Text_Plain("nested1\n\nnested2"), 'nest');
     $element->accept(new T_Text_ParagraphLexer());
     $this->assertEquals($expected, $element);
 }
예제 #10
0
파일: Text.php 프로젝트: robtuley/knotwerk
 function testCanRenderMultipleInternalLinks()
 {
     $wiki = new T_Text_Plain('parent');
     $wiki->addChild(new T_Text_InternalLink('content1', '/url1'));
     $wiki->addChild(new T_Text_InternalLink('content2', '/url2'));
     $url1 = $this->getRootUrl()->__toString() . '/url1';
     $url2 = $this->getRootUrl()->__toString() . '/url2';
     $expect = 'parent' . '<a href="' . $url1 . '">content1</a>' . '<a href="' . $url2 . '">content2</a>';
     $this->assertSame($expect, $this->getVisitorRender($wiki));
 }