xref: /dokuwiki/_test/tests/Parsing/ParserMode/QuoteTest.php (revision 504c13e8df88563c11b3720b317991bc38835a35)
1*504c13e8SAndreas Gohr<?php
2*504c13e8SAndreas Gohr
3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode;
4*504c13e8SAndreas Gohr
5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Eol;
6*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Quote;
7*504c13e8SAndreas Gohr
8*504c13e8SAndreas Gohrclass QuoteTest extends ParserTestBase
9*504c13e8SAndreas Gohr{
10*504c13e8SAndreas Gohr
11*504c13e8SAndreas Gohr    function testQuote() {
12*504c13e8SAndreas Gohr        $this->P->addMode('quote',new Quote());
13*504c13e8SAndreas Gohr        $this->P->parse("abc\n> def\n>>ghi\nklm");
14*504c13e8SAndreas Gohr        $calls = [
15*504c13e8SAndreas Gohr            ['document_start',[]],
16*504c13e8SAndreas Gohr            ['p_open',[]],
17*504c13e8SAndreas Gohr            ['cdata',["\nabc"]],
18*504c13e8SAndreas Gohr            ['p_close',[]],
19*504c13e8SAndreas Gohr            ['quote_open',[]],
20*504c13e8SAndreas Gohr            ['cdata',[" def"]],
21*504c13e8SAndreas Gohr            ['quote_open',[]],
22*504c13e8SAndreas Gohr            ['cdata',["ghi"]],
23*504c13e8SAndreas Gohr            ['quote_close',[]],
24*504c13e8SAndreas Gohr            ['quote_close',[]],
25*504c13e8SAndreas Gohr            ['p_open',[]],
26*504c13e8SAndreas Gohr            ['cdata',["klm"]],
27*504c13e8SAndreas Gohr            ['p_close',[]],
28*504c13e8SAndreas Gohr            ['document_end',[]],
29*504c13e8SAndreas Gohr
30*504c13e8SAndreas Gohr        ];
31*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
32*504c13e8SAndreas Gohr    }
33*504c13e8SAndreas Gohr
34*504c13e8SAndreas Gohr    function testQuoteWinCr() {
35*504c13e8SAndreas Gohr        $this->P->addMode('quote',new Quote());
36*504c13e8SAndreas Gohr        $this->P->parse("abc\r\n> def\r\n>>ghi\r\nklm");
37*504c13e8SAndreas Gohr        $calls = [
38*504c13e8SAndreas Gohr            ['document_start',[]],
39*504c13e8SAndreas Gohr            ['p_open',[]],
40*504c13e8SAndreas Gohr            ['cdata',["\nabc"]],
41*504c13e8SAndreas Gohr            ['p_close',[]],
42*504c13e8SAndreas Gohr            ['quote_open',[]],
43*504c13e8SAndreas Gohr            ['cdata',[" def"]],
44*504c13e8SAndreas Gohr            ['quote_open',[]],
45*504c13e8SAndreas Gohr            ['cdata',["ghi"]],
46*504c13e8SAndreas Gohr            ['quote_close',[]],
47*504c13e8SAndreas Gohr            ['quote_close',[]],
48*504c13e8SAndreas Gohr            ['p_open',[]],
49*504c13e8SAndreas Gohr            ['cdata',["klm"]],
50*504c13e8SAndreas Gohr            ['p_close',[]],
51*504c13e8SAndreas Gohr            ['document_end',[]],
52*504c13e8SAndreas Gohr
53*504c13e8SAndreas Gohr        ];
54*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
55*504c13e8SAndreas Gohr    }
56*504c13e8SAndreas Gohr
57*504c13e8SAndreas Gohr    function testQuoteMinumumContext() {
58*504c13e8SAndreas Gohr        $this->P->addMode('quote',new Quote());
59*504c13e8SAndreas Gohr        $this->P->parse("\n> def\n>>ghi\n ");
60*504c13e8SAndreas Gohr        $calls = [
61*504c13e8SAndreas Gohr            ['document_start',[]],
62*504c13e8SAndreas Gohr            ['quote_open',[]],
63*504c13e8SAndreas Gohr            ['cdata',[" def"]],
64*504c13e8SAndreas Gohr            ['quote_open',[]],
65*504c13e8SAndreas Gohr            ['cdata',["ghi"]],
66*504c13e8SAndreas Gohr            ['quote_close',[]],
67*504c13e8SAndreas Gohr            ['quote_close',[]],
68*504c13e8SAndreas Gohr            ['document_end',[]],
69*504c13e8SAndreas Gohr
70*504c13e8SAndreas Gohr        ];
71*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
72*504c13e8SAndreas Gohr    }
73*504c13e8SAndreas Gohr
74*504c13e8SAndreas Gohr    function testQuoteEol() {
75*504c13e8SAndreas Gohr        $this->P->addMode('quote',new Quote());
76*504c13e8SAndreas Gohr        $this->P->addMode('eol',new Eol());
77*504c13e8SAndreas Gohr        $this->P->parse("abc\n> def\n>>ghi\nklm");
78*504c13e8SAndreas Gohr        $calls = [
79*504c13e8SAndreas Gohr            ['document_start',[]],
80*504c13e8SAndreas Gohr            ['p_open',[]],
81*504c13e8SAndreas Gohr            ['cdata',["abc"]],
82*504c13e8SAndreas Gohr            ['p_close',[]],
83*504c13e8SAndreas Gohr            ['quote_open',[]],
84*504c13e8SAndreas Gohr            ['cdata',[" def"]],
85*504c13e8SAndreas Gohr            ['quote_open',[]],
86*504c13e8SAndreas Gohr            ['cdata',["ghi"]],
87*504c13e8SAndreas Gohr            ['quote_close',[]],
88*504c13e8SAndreas Gohr            ['quote_close',[]],
89*504c13e8SAndreas Gohr            ['p_open',[]],
90*504c13e8SAndreas Gohr            ['cdata',["klm"]],
91*504c13e8SAndreas Gohr            ['p_close',[]],
92*504c13e8SAndreas Gohr            ['document_end',[]],
93*504c13e8SAndreas Gohr
94*504c13e8SAndreas Gohr        ];
95*504c13e8SAndreas Gohr        $this->assertCalls($calls, $this->H->calls);
96*504c13e8SAndreas Gohr    }
97*504c13e8SAndreas Gohr
98*504c13e8SAndreas Gohr}
99