1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Rss; 6*504c13e8SAndreas Gohr 7*504c13e8SAndreas Gohrclass RssTest extends ParserTestBase 8*504c13e8SAndreas Gohr{ 9*504c13e8SAndreas Gohr function setUp(): void 10*504c13e8SAndreas Gohr { 11*504c13e8SAndreas Gohr parent::setUp(); 12*504c13e8SAndreas Gohr $this->P->addMode('rss', new Rss()); 13*504c13e8SAndreas Gohr } 14*504c13e8SAndreas Gohr 15*504c13e8SAndreas Gohr function testRssBasic() 16*504c13e8SAndreas Gohr { 17*504c13e8SAndreas Gohr $this->P->parse('Foo {{rss>http://example.com/feed}} Bar'); 18*504c13e8SAndreas Gohr $calls = [ 19*504c13e8SAndreas Gohr ['document_start', []], 20*504c13e8SAndreas Gohr ['p_open', []], 21*504c13e8SAndreas Gohr ['cdata', ["\nFoo "]], 22*504c13e8SAndreas Gohr ['p_close', []], 23*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 24*504c13e8SAndreas Gohr 'max' => 8, 25*504c13e8SAndreas Gohr 'reverse' => 0, 26*504c13e8SAndreas Gohr 'author' => 0, 27*504c13e8SAndreas Gohr 'date' => 0, 28*504c13e8SAndreas Gohr 'details' => 0, 29*504c13e8SAndreas Gohr 'nosort' => 0, 30*504c13e8SAndreas Gohr 'refresh' => 14400, 31*504c13e8SAndreas Gohr ]]], 32*504c13e8SAndreas Gohr ['p_open', []], 33*504c13e8SAndreas Gohr ['cdata', [' Bar']], 34*504c13e8SAndreas Gohr ['p_close', []], 35*504c13e8SAndreas Gohr ['document_end', []], 36*504c13e8SAndreas Gohr ]; 37*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 38*504c13e8SAndreas Gohr } 39*504c13e8SAndreas Gohr 40*504c13e8SAndreas Gohr function testRssMaxItems() 41*504c13e8SAndreas Gohr { 42*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed 5}}'); 43*504c13e8SAndreas Gohr $calls = [ 44*504c13e8SAndreas Gohr ['document_start', []], 45*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 46*504c13e8SAndreas Gohr 'max' => '5', 47*504c13e8SAndreas Gohr 'reverse' => 0, 48*504c13e8SAndreas Gohr 'author' => 0, 49*504c13e8SAndreas Gohr 'date' => 0, 50*504c13e8SAndreas Gohr 'details' => 0, 51*504c13e8SAndreas Gohr 'nosort' => 0, 52*504c13e8SAndreas Gohr 'refresh' => 14400, 53*504c13e8SAndreas Gohr ]]], 54*504c13e8SAndreas Gohr ['document_end', []], 55*504c13e8SAndreas Gohr ]; 56*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 57*504c13e8SAndreas Gohr } 58*504c13e8SAndreas Gohr 59*504c13e8SAndreas Gohr function testRssAllParams() 60*504c13e8SAndreas Gohr { 61*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed 3 rev author date desc nosort 2h}}'); 62*504c13e8SAndreas Gohr $calls = [ 63*504c13e8SAndreas Gohr ['document_start', []], 64*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 65*504c13e8SAndreas Gohr 'max' => '3', 66*504c13e8SAndreas Gohr 'reverse' => 1, 67*504c13e8SAndreas Gohr 'author' => 1, 68*504c13e8SAndreas Gohr 'date' => 1, 69*504c13e8SAndreas Gohr 'details' => 1, 70*504c13e8SAndreas Gohr 'nosort' => 1, 71*504c13e8SAndreas Gohr 'refresh' => 7200, 72*504c13e8SAndreas Gohr ]]], 73*504c13e8SAndreas Gohr ['document_end', []], 74*504c13e8SAndreas Gohr ]; 75*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 76*504c13e8SAndreas Gohr } 77*504c13e8SAndreas Gohr 78*504c13e8SAndreas Gohr function testRssRefreshDays() 79*504c13e8SAndreas Gohr { 80*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed 1d}}'); 81*504c13e8SAndreas Gohr $calls = [ 82*504c13e8SAndreas Gohr ['document_start', []], 83*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 84*504c13e8SAndreas Gohr 'max' => 8, 85*504c13e8SAndreas Gohr 'reverse' => 0, 86*504c13e8SAndreas Gohr 'author' => 0, 87*504c13e8SAndreas Gohr 'date' => 0, 88*504c13e8SAndreas Gohr 'details' => 0, 89*504c13e8SAndreas Gohr 'nosort' => 0, 90*504c13e8SAndreas Gohr 'refresh' => 86400, 91*504c13e8SAndreas Gohr ]]], 92*504c13e8SAndreas Gohr ['document_end', []], 93*504c13e8SAndreas Gohr ]; 94*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 95*504c13e8SAndreas Gohr } 96*504c13e8SAndreas Gohr 97*504c13e8SAndreas Gohr function testRssRefreshMinimum() 98*504c13e8SAndreas Gohr { 99*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed 1m}}'); 100*504c13e8SAndreas Gohr $calls = [ 101*504c13e8SAndreas Gohr ['document_start', []], 102*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 103*504c13e8SAndreas Gohr 'max' => 8, 104*504c13e8SAndreas Gohr 'reverse' => 0, 105*504c13e8SAndreas Gohr 'author' => 0, 106*504c13e8SAndreas Gohr 'date' => 0, 107*504c13e8SAndreas Gohr 'details' => 0, 108*504c13e8SAndreas Gohr 'nosort' => 0, 109*504c13e8SAndreas Gohr 'refresh' => 600, 110*504c13e8SAndreas Gohr ]]], 111*504c13e8SAndreas Gohr ['document_end', []], 112*504c13e8SAndreas Gohr ]; 113*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 114*504c13e8SAndreas Gohr } 115*504c13e8SAndreas Gohr 116*504c13e8SAndreas Gohr function testRssDetailAlias() 117*504c13e8SAndreas Gohr { 118*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed detail}}'); 119*504c13e8SAndreas Gohr $calls = [ 120*504c13e8SAndreas Gohr ['document_start', []], 121*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 122*504c13e8SAndreas Gohr 'max' => 8, 123*504c13e8SAndreas Gohr 'reverse' => 0, 124*504c13e8SAndreas Gohr 'author' => 0, 125*504c13e8SAndreas Gohr 'date' => 0, 126*504c13e8SAndreas Gohr 'details' => 1, 127*504c13e8SAndreas Gohr 'nosort' => 0, 128*504c13e8SAndreas Gohr 'refresh' => 14400, 129*504c13e8SAndreas Gohr ]]], 130*504c13e8SAndreas Gohr ['document_end', []], 131*504c13e8SAndreas Gohr ]; 132*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 133*504c13e8SAndreas Gohr } 134*504c13e8SAndreas Gohr 135*504c13e8SAndreas Gohr function testRssAuthorAlias() 136*504c13e8SAndreas Gohr { 137*504c13e8SAndreas Gohr $this->P->parse('{{rss>http://example.com/feed by}}'); 138*504c13e8SAndreas Gohr $calls = [ 139*504c13e8SAndreas Gohr ['document_start', []], 140*504c13e8SAndreas Gohr ['rss', ['http://example.com/feed', [ 141*504c13e8SAndreas Gohr 'max' => 8, 142*504c13e8SAndreas Gohr 'reverse' => 0, 143*504c13e8SAndreas Gohr 'author' => 1, 144*504c13e8SAndreas Gohr 'date' => 0, 145*504c13e8SAndreas Gohr 'details' => 0, 146*504c13e8SAndreas Gohr 'nosort' => 0, 147*504c13e8SAndreas Gohr 'refresh' => 14400, 148*504c13e8SAndreas Gohr ]]], 149*504c13e8SAndreas Gohr ['document_end', []], 150*504c13e8SAndreas Gohr ]; 151*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 152*504c13e8SAndreas Gohr } 153*504c13e8SAndreas Gohr 154*504c13e8SAndreas Gohr function testRssNotMatched() 155*504c13e8SAndreas Gohr { 156*504c13e8SAndreas Gohr $this->P->parse('Foo {{rss>}} Bar'); 157*504c13e8SAndreas Gohr $calls = [ 158*504c13e8SAndreas Gohr ['document_start', []], 159*504c13e8SAndreas Gohr ['p_open', []], 160*504c13e8SAndreas Gohr ['cdata', ["\nFoo {{rss>}} Bar"]], 161*504c13e8SAndreas Gohr ['p_close', []], 162*504c13e8SAndreas Gohr ['document_end', []], 163*504c13e8SAndreas Gohr ]; 164*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 165*504c13e8SAndreas Gohr } 166*504c13e8SAndreas Gohr} 167