1*545c554bSsaggi-dw<?php 2*545c554bSsaggi-dw 3*545c554bSsaggi-dwnamespace dokuwiki\plugin\dwtimeline\test; 4*545c554bSsaggi-dw 5*545c554bSsaggi-dwuse DokuWikiTest; 6*545c554bSsaggi-dw 7*545c554bSsaggi-dw/** 8*545c554bSsaggi-dw * Tests for <dwtimeline page=... /> 9*545c554bSsaggi-dw * 10*545c554bSsaggi-dw * @group plugin_dwtimeline 11*545c554bSsaggi-dw * @group plugins 12*545c554bSsaggi-dw */ 13*545c554bSsaggi-dwclass RenderPageTimelineTest extends DokuWikiTest 14*545c554bSsaggi-dw{ 15*545c554bSsaggi-dw protected $pluginsEnabled = ['dwtimeline']; 16*545c554bSsaggi-dw 17*545c554bSsaggi-dw public function setUp(): void 18*545c554bSsaggi-dw { 19*545c554bSsaggi-dw parent::setUp(); 20*545c554bSsaggi-dw } 21*545c554bSsaggi-dw 22*545c554bSsaggi-dw public function test_renders_title_and_milestones() 23*545c554bSsaggi-dw { 24*545c554bSsaggi-dw // Prepare a source page with H1 + H2 + content 25*545c554bSsaggi-dw $srcId = 'playground:source'; 26*545c554bSsaggi-dw $wikitext = <<<TXT 27*545c554bSsaggi-dw====== Project Alpha ====== 28*545c554bSsaggi-dw===== Kickoff ===== 29*545c554bSsaggi-dwIntro text. 30*545c554bSsaggi-dw 31*545c554bSsaggi-dw===== Build ===== 32*545c554bSsaggi-dwBuild details. 33*545c554bSsaggi-dw 34*545c554bSsaggi-dw==== Substep A ==== 35*545c554bSsaggi-dwMore details. 36*545c554bSsaggi-dw 37*545c554bSsaggi-dw===== Launch ===== 38*545c554bSsaggi-dwFinal text. 39*545c554bSsaggi-dwTXT; 40*545c554bSsaggi-dw saveWikiText($srcId, $wikitext, 'setup'); 41*545c554bSsaggi-dw 42*545c554bSsaggi-dw // Render a page that uses renderpage 43*545c554bSsaggi-dw $pageId = 'playground:target'; 44*545c554bSsaggi-dw $targetText = '<dwtimeline page=' . $srcId . ' />'; 45*545c554bSsaggi-dw $html = p_render('xhtml', p_get_instructions($targetText), $info); 46*545c554bSsaggi-dw 47*545c554bSsaggi-dw // Title must appear 48*545c554bSsaggi-dw $this->assertStringContainsString('Project Alpha', $html, 'Timeline title missing'); 49*545c554bSsaggi-dw 50*545c554bSsaggi-dw // Milestone titles must appear 51*545c554bSsaggi-dw $this->assertStringContainsString('Kickoff', $html); 52*545c554bSsaggi-dw $this->assertStringContainsString('Build', $html); 53*545c554bSsaggi-dw $this->assertStringContainsString('Launch', $html); 54*545c554bSsaggi-dw 55*545c554bSsaggi-dw // Body content of first milestone should be included 56*545c554bSsaggi-dw $this->assertStringContainsString('Intro text.', $html); 57*545c554bSsaggi-dw 58*545c554bSsaggi-dw // Body content of "Build" should include its H3 section text 59*545c554bSsaggi-dw $this->assertStringContainsString('Build details.', $html); 60*545c554bSsaggi-dw $this->assertStringContainsString('More details.', $html); 61*545c554bSsaggi-dw } 62*545c554bSsaggi-dw 63*545c554bSsaggi-dw public function test_non_existing_page() 64*545c554bSsaggi-dw { 65*545c554bSsaggi-dw $srcId = 'no:such:page'; 66*545c554bSsaggi-dw $html = p_render('xhtml', p_get_instructions('<dwtimeline page=' . $srcId . ' />'), $info); 67*545c554bSsaggi-dw $this->assertStringContainsString('Page not found:', strip_tags($html), 'Missing not-found message key'); 68*545c554bSsaggi-dw } 69*545c554bSsaggi-dw 70*545c554bSsaggi-dw public function test_self_include_guard() 71*545c554bSsaggi-dw { 72*545c554bSsaggi-dw $srcId = 'playground:self'; 73*545c554bSsaggi-dw $wikitext = "====== Self test ======\n\n<dwtimeline page=$srcId />"; 74*545c554bSsaggi-dw saveWikiText($srcId, $wikitext, 'setup'); 75*545c554bSsaggi-dw $html = p_wiki_xhtml($srcId); 76*545c554bSsaggi-dw $this->assertTrue( 77*545c554bSsaggi-dw str_contains(strip_tags($html), 'Source and destination are equal:'), 78*545c554bSsaggi-dw 'Missing same-page guard' 79*545c554bSsaggi-dw ); 80*545c554bSsaggi-dw } 81*545c554bSsaggi-dw} 82