1<?php
2/**
3 * @group plugin_pageimage
4 * @group plugins
5 */
6class helper_plugin_pageimage_test extends DokuwikiTest {
7    protected $pluginsEnabled = array('pageimage');
8
9    private $helper;
10    public function setUp(){
11        parent::setUp();
12        $this->helper = plugin_load('helper', 'pageimage');
13    }
14
15    public function test_imageSet_imagemissing() {
16        saveWikiText('pageimage:page','~~PAGEIMAGE:pageimage:png~~','Test setup');
17
18        $imageID = $this->helper->getImageID('pageimage:page');
19        $this->assertEquals('',$imageID);
20    }
21
22    public function test_imageSet_imageexists() {
23        saveWikiText('pageimage:page','~~PAGEIMAGE:wiki:dokuwiki-128.png~~','Test setup');
24
25        $imageID = $this->helper->getImageID('pageimage:page');
26        $this->assertEquals('wiki:dokuwiki-128.png',$imageID);
27    }
28
29    public function test_image_same_as_page() {
30        saveWikiText('wiki:dokuwiki-128','blorg','Test setup');
31
32        $imageID = $this->helper->getImageID('wiki:dokuwiki-128');
33        $this->assertEquals('wiki:dokuwiki-128.png',$imageID);
34    }
35
36    public function test_image_firstimage() {
37        saveWikiText('pageimage:page','{{wiki:dokuwiki-128.png}}','Test setup');
38        $imageID = $this->helper->getImageID('pageimage:page',array('firstimage'=>1));
39        $this->assertEquals('wiki:dokuwiki-128.png',$imageID);
40    }
41
42
43
44
45
46
47}