1<?php
2
3namespace dokuwiki\plugin\dw2pdf\test;
4
5use DokuWikiTest;
6
7/**
8 * Export link tests for the dw2pdf plugin
9 *
10 * @group plugin_dw2pdf
11 * @group plugins
12 */
13class SyntaxExportLinkTest extends DokuWikiTest
14{
15
16    protected $pluginsEnabled = array('dw2pdf');
17
18    function testParser()
19    {
20        global $ID;
21        $ID = 'foo:bar:start';
22        $parser_response = p_get_instructions('~~PDFNS>.:|Foo~~');
23        $expected_parser_response = array(
24            'plugin',
25            array(
26                'dw2pdf_exportlink',
27                array(
28                    'link' => '?do=export_pdfns&book_ns=foo:bar&book_title=Foo',
29                    'title' => 'Export namespace "foo:bar:" to file Foo.pdf',
30                    5,
31                    1,
32                ),
33                5,
34                '~~PDFNS>.:|Foo~~',
35            ),
36            1,
37        );
38        $this->assertEquals($expected_parser_response, $parser_response[2]);
39        $renderer_response = p_render('xhtml', $parser_response, $info);
40        $expected_renderer_response = 'doku.php?id=foo:bar:start&amp;do=export_pdfns&amp;book_ns=foo:bar&amp;book_title=Foo" class="wikilink2" title="foo:bar:start" rel="nofollow" data-wiki-id="foo:bar:start">Export namespace &quot;foo:bar:&quot; to file Foo.pdf</a>';
41        $trimmed_renderer_response = substr($renderer_response, strpos($renderer_response, 'doku.php'), -5);
42        $trimmed_renderer_response = trim($trimmed_renderer_response);
43        $this->assertEquals($expected_renderer_response, $trimmed_renderer_response);
44    }
45}
46
47