1*fe9d054bSAndreas Gohr<?php 2*fe9d054bSAndreas Gohr 3*fe9d054bSAndreas Gohrnamespace dokuwiki\test\Feed; 4*fe9d054bSAndreas Gohr 5*fe9d054bSAndreas Gohruse dokuwiki\Feed\FeedMediaProcessor; 6*fe9d054bSAndreas Gohruse DOMWrap\Document; 7*fe9d054bSAndreas Gohr 8*fe9d054bSAndreas Gohrclass FeedMediaProcessorTest extends \DokuWikiTest 9*fe9d054bSAndreas Gohr{ 10*fe9d054bSAndreas Gohr 11*fe9d054bSAndreas Gohr public function provideData() 12*fe9d054bSAndreas Gohr { 13*fe9d054bSAndreas Gohr // an Item returned by FeedCreator::fetchItemsFromRecentChanges() 14*fe9d054bSAndreas Gohr yield ([ 15*fe9d054bSAndreas Gohr array( 16*fe9d054bSAndreas Gohr 'date' => 1705511543, 17*fe9d054bSAndreas Gohr 'ip' => '::1', 18*fe9d054bSAndreas Gohr 'type' => 'C', 19*fe9d054bSAndreas Gohr 'id' => 'wiki:dokuwiki-128.png', 20*fe9d054bSAndreas Gohr 'user' => 'testuser', 21*fe9d054bSAndreas Gohr 'sum' => 'created', 22*fe9d054bSAndreas Gohr 'extra' => '', 23*fe9d054bSAndreas Gohr 'sizechange' => 52618, 24*fe9d054bSAndreas Gohr 'perms' => 8, 25*fe9d054bSAndreas Gohr 'mode' => 'media', 26*fe9d054bSAndreas Gohr ), 27*fe9d054bSAndreas Gohr 1705511543, // fixed revision 28*fe9d054bSAndreas Gohr ['testuser@undisclosed.example.com', 'Arthur Dent'], // proper author 29*fe9d054bSAndreas Gohr 'created', // summary 30*fe9d054bSAndreas Gohr ]); 31*fe9d054bSAndreas Gohr 32*fe9d054bSAndreas Gohr // FeedCreator::fetchItemsFromNamespace() currently does not support media files 33*fe9d054bSAndreas Gohr // FeedCreator::fetchItemsFromSearch() currently does not support media files 34*fe9d054bSAndreas Gohr } 35*fe9d054bSAndreas Gohr 36*fe9d054bSAndreas Gohr 37*fe9d054bSAndreas Gohr /** 38*fe9d054bSAndreas Gohr * @dataProvider provideData 39*fe9d054bSAndreas Gohr */ 40*fe9d054bSAndreas Gohr public function testProcessing($data, $expectedMtime, $expectedAuthor, $expectedSummary) 41*fe9d054bSAndreas Gohr { 42*fe9d054bSAndreas Gohr global $conf; 43*fe9d054bSAndreas Gohr $conf['useacl'] = 1; 44*fe9d054bSAndreas Gohr $conf['showuseras'] = 'username'; 45*fe9d054bSAndreas Gohr $conf['useheading'] = 1; 46*fe9d054bSAndreas Gohr 47*fe9d054bSAndreas Gohr $proc = new FeedMediaProcessor($data); 48*fe9d054bSAndreas Gohr 49*fe9d054bSAndreas Gohr $this->assertEquals('wiki:dokuwiki-128.png', $proc->getId()); 50*fe9d054bSAndreas Gohr $this->assertEquals('dokuwiki-128.png', $proc->getTitle()); 51*fe9d054bSAndreas Gohr $this->assertEquals($expectedAuthor, $proc->getAuthor()); 52*fe9d054bSAndreas Gohr $this->assertEquals($expectedMtime, $proc->getRev()); 53*fe9d054bSAndreas Gohr $this->assertEquals(null, $proc->getPrev()); 54*fe9d054bSAndreas Gohr $this->assertTrue($proc->isExisting()); 55*fe9d054bSAndreas Gohr $this->assertTrue($proc->isExisting()); 56*fe9d054bSAndreas Gohr $this->assertEquals(['wiki'], $proc->getCategory()); 57*fe9d054bSAndreas Gohr $this->assertEquals($expectedSummary, $proc->getSummary()); 58*fe9d054bSAndreas Gohr 59*fe9d054bSAndreas Gohr $this->assertEquals( 60*fe9d054bSAndreas Gohr "http://wiki.example.com/doku.php?image=wiki%3Adokuwiki-128.png&ns=wiki&rev=$expectedMtime&do=media", 61*fe9d054bSAndreas Gohr $proc->getURL('page') 62*fe9d054bSAndreas Gohr ); 63*fe9d054bSAndreas Gohr $this->assertEquals( 64*fe9d054bSAndreas Gohr "http://wiki.example.com/doku.php?image=wiki%3Adokuwiki-128.png&ns=wiki&rev=$expectedMtime&tab_details=history&do=media", 65*fe9d054bSAndreas Gohr $proc->getURL('rev') 66*fe9d054bSAndreas Gohr ); 67*fe9d054bSAndreas Gohr $this->assertEquals( 68*fe9d054bSAndreas Gohr "http://wiki.example.com/doku.php?image=wiki%3Adokuwiki-128.png&ns=wiki&do=media", 69*fe9d054bSAndreas Gohr $proc->getURL('current') 70*fe9d054bSAndreas Gohr ); 71*fe9d054bSAndreas Gohr $this->assertEquals( 72*fe9d054bSAndreas Gohr "http://wiki.example.com/doku.php?image=wiki%3Adokuwiki-128.png&ns=wiki&rev=$expectedMtime&tab_details=history&media_do=diff&do=media", 73*fe9d054bSAndreas Gohr $proc->getURL('diff') 74*fe9d054bSAndreas Gohr ); 75*fe9d054bSAndreas Gohr 76*fe9d054bSAndreas Gohr 77*fe9d054bSAndreas Gohr $doc = new Document(); 78*fe9d054bSAndreas Gohr $doc->html($proc->getBody('diff')); 79*fe9d054bSAndreas Gohr $th = $doc->find('table th'); 80*fe9d054bSAndreas Gohr $this->assertGreaterThanOrEqual(2, $th->count()); 81*fe9d054bSAndreas Gohr 82*fe9d054bSAndreas Gohr $doc = new Document(); 83*fe9d054bSAndreas Gohr $doc->html($proc->getBody('htmldiff')); 84*fe9d054bSAndreas Gohr $th = $doc->find('table th'); 85*fe9d054bSAndreas Gohr $this->assertGreaterThanOrEqual(2, $th->count()); 86*fe9d054bSAndreas Gohr 87*fe9d054bSAndreas Gohr $doc = new Document(); 88*fe9d054bSAndreas Gohr $doc->html($proc->getBody('html')); 89*fe9d054bSAndreas Gohr $home = $doc->find('img'); 90*fe9d054bSAndreas Gohr $this->assertEquals(1, $home->count()); 91*fe9d054bSAndreas Gohr } 92*fe9d054bSAndreas Gohr 93*fe9d054bSAndreas Gohr} 94