1<?php
2
3namespace dokuwiki\plugin\dw2pdf\test;
4
5use dokuwiki\plugin\dw2pdf\DokuImageProcessorDecorator;
6use DokuWikiTest;
7
8/**
9 * General tests for the imagemap plugin
10 *
11 * @group plugin_dw2pdf
12 * @group plugins
13 */
14class DokuImageProcessorTest extends DokuWikiTest
15{
16
17    /**
18     * @return array the Testdata
19     */
20    public function provideGetImageTestdata() {
21        global $conf;
22
23        return [
24            [
25                DOKU_URL . 'lib/exe/fetch.php?tok=b0b7a3&media=http%3A%2F%2Fphp.net%2Fimages%2Fphp.gif',
26                DOKU_REL . 'lib/exe/fetch.php?tok=b0b7a3&media=http%3A%2F%2Fphp.net%2Fimages%2Fphp.gif',
27                'http://php.net/images/php.gif',
28                'http://php.net/images/php.gif',
29                'external image',
30            ],
31            [
32                DOKU_URL . 'lib/images/throbber.gif',
33                DOKU_REL . 'lib/images/throbber.gif',
34                DOKU_INC . 'lib/images/throbber.gif',
35                DOKU_INC . 'lib/images/throbber.gif',
36                'fixed standard image',
37            ],
38            [
39                DOKU_URL . 'lib/exe/fetch.php?media=wiki:dokuwiki-128.png',
40                DOKU_REL . 'lib/exe/fetch.php?media=wiki:dokuwiki-128.png',
41                $conf['mediadir'] . '/wiki/dokuwiki-128.png',
42                $conf['mediadir'] . '/wiki/dokuwiki-128.png',
43                'Internal image',
44            ],
45        ];
46    }
47
48    /**
49     * @dataProvider provideGetImageTestdata
50     *
51     * @param $input_file
52     * @param $input_orig_srcpath
53     * @param $expected_file
54     * @param $expected_orig_srcpath
55     * @param $msg
56     */
57    public function testGetImage($input_file, $input_orig_srcpath, $expected_file, $expected_orig_srcpath, $msg)
58    {
59
60        list($actual_file, $actual_orig_srcpath) = DokuImageProcessorDecorator::adjustGetImageLinks($input_file,
61            $input_orig_srcpath);
62
63        $this->assertEquals($expected_file, $actual_file,  '$file ' . $msg);
64        $this->assertEquals($expected_orig_srcpath, $actual_orig_srcpath,  '$orig_srcpath ' . $msg);
65    }
66
67}
68