1*92200750SAndreas Gohr<?php 2*92200750SAndreas Gohr 3*92200750SAndreas Gohrnamespace dokuwiki\plugin\dw2pdf\test; 4*92200750SAndreas Gohr 5*92200750SAndreas Gohruse dokuwiki\plugin\dw2pdf\src\AbstractCollector; 6*92200750SAndreas Gohruse dokuwiki\plugin\dw2pdf\src\Config; 7*92200750SAndreas Gohruse dokuwiki\plugin\dw2pdf\src\PageCollector; 8*92200750SAndreas Gohruse dokuwiki\plugin\dw2pdf\src\Template; 9*92200750SAndreas Gohruse DokuWikiTest; 10*92200750SAndreas Gohr 11*92200750SAndreas Gohr/** 12*92200750SAndreas Gohr * @group plugin_dw2pdf 13*92200750SAndreas Gohr * @group plugins 14*92200750SAndreas Gohr */ 15*92200750SAndreas Gohrclass TemplateTest extends DokuWikiTest 16*92200750SAndreas Gohr{ 17*92200750SAndreas Gohr public function setUp(): void 18*92200750SAndreas Gohr { 19*92200750SAndreas Gohr parent::setUp(); 20*92200750SAndreas Gohr $_REQUEST = []; 21*92200750SAndreas Gohr } 22*92200750SAndreas Gohr 23*92200750SAndreas Gohr /** 24*92200750SAndreas Gohr * Template placeholders (title, username, QR codes, links) should be expanded from context data. 25*92200750SAndreas Gohr */ 26*92200750SAndreas Gohr public function testPlaceholderReplacement(): void 27*92200750SAndreas Gohr { 28*92200750SAndreas Gohr global $ID, $INPUT, $conf; 29*92200750SAndreas Gohr $INPUT->set('book_title', 'Export Title'); 30*92200750SAndreas Gohr $ID = 'playground:templatepage'; 31*92200750SAndreas Gohr saveWikiText($ID, 'template test', 'create'); 32*92200750SAndreas Gohr 33*92200750SAndreas Gohr $config = new Config([ 34*92200750SAndreas Gohr 'qrcodescale' => 1.5, 35*92200750SAndreas Gohr ]); 36*92200750SAndreas Gohr 37*92200750SAndreas Gohr $collector = new PageCollector($config); 38*92200750SAndreas Gohr $template = new Template($config); 39*92200750SAndreas Gohr $template->setContext($collector, $ID, 'username'); 40*92200750SAndreas Gohr 41*92200750SAndreas Gohr $html = $template->getHTML('unittest'); 42*92200750SAndreas Gohr 43*92200750SAndreas Gohr $this->assertStringContainsString('Page Number: {PAGENO}', $html); 44*92200750SAndreas Gohr $this->assertStringContainsString('Total Pages: {nbpg}', $html); 45*92200750SAndreas Gohr $this->assertStringContainsString('Document Title: Export Title', $html); 46*92200750SAndreas Gohr $this->assertStringContainsString('Wiki Title: ' . $conf['title'], $html); 47*92200750SAndreas Gohr $this->assertStringContainsString('Wiki URL: ' . DOKU_URL, $html); 48*92200750SAndreas Gohr $this->assertStringNotContainsString('@DATE@', $html); 49*92200750SAndreas Gohr $this->assertStringContainsString('User: username', $html); 50*92200750SAndreas Gohr $this->assertStringContainsString('Base Path: ' . DOKU_BASE, $html); 51*92200750SAndreas Gohr $this->assertStringContainsString('Include Dir: ' . DOKU_INC, $html); 52*92200750SAndreas Gohr $this->assertStringContainsString('Template Base Path: ' . DOKU_BASE . 'lib/plugins/dw2pdf/tpl/default/', $html); 53*92200750SAndreas Gohr $this->assertStringContainsString('Template Include Dir: ' . DOKU_INC . 'lib/plugins/dw2pdf/tpl/default/', $html); 54*92200750SAndreas Gohr $this->assertStringContainsString('Page ID: ' . $ID, $html); 55*92200750SAndreas Gohr 56*92200750SAndreas Gohr $revisionDate = dformat(filemtime(wikiFN($ID))); 57*92200750SAndreas Gohr $this->assertStringContainsString('Revision: ' . $revisionDate, $html); 58*92200750SAndreas Gohr 59*92200750SAndreas Gohr $pageUrl = wl($ID, [], true, '&'); 60*92200750SAndreas Gohr $this->assertStringContainsString('Page URL: ' . $pageUrl, $html); 61*92200750SAndreas Gohr $this->assertStringContainsString('<barcode', $html); 62*92200750SAndreas Gohr $this->assertStringContainsString('size="1.5"', $html); 63*92200750SAndreas Gohr $this->assertStringNotContainsString('@QRCODE@', $html); 64*92200750SAndreas Gohr } 65*92200750SAndreas Gohr} 66