1<?php
2
3/**
4 * Syntax tests for the latexit plugin
5 *
6 * @group plugin_latexit
7 * @group plugins
8 */
9class syntax_plugin_latexit_base_test extends DokuWikiTest {
10
11    /**
12     * These plugins will be loaded for testing.
13     * @var array
14     */
15    protected $pluginsEnabled = array('latexit', 'mathjax', 'imagereference', 'zotero');
16    /**
17     * Variable to store the instance of syntax plugin.
18     * @var syntax_plugin_latexit
19     */
20    protected $s;
21
22    /**
23     * Prepares the testing environment.
24     */
25    public function setUp() {
26        parent::setUp();
27
28        $this->s = new syntax_plugin_latexit_base();
29    }
30
31    /**
32     * Testing getType method.
33     */
34    public function test_getType() {
35        $this->assertEquals("substition", $this->s->getType());
36    }
37
38    /**
39     * Testing getSort method.
40     */
41    public function test_getSort() {
42        $this->assertEquals(245, $this->s->getSort());
43        $this->s->_setSort(25);
44        $this->assertEquals(25, $this->s->getSort());
45    }
46
47    /**
48     * Testing isSingleton method.
49     */
50    public function test_isSingleton() {
51        $this->assertTrue($this->s->isSingleton());
52    }
53
54    /**
55     * Testing handle method.
56     */
57    public function test_handle() {
58        //test zotero part of the method
59        $r = $this->s->handle("\cite{bibliography}", "", 0, new Doku_Handler());
60        $this->assertEquals("bibliography", $r);
61
62        //test recursive insertion part of the method
63        $r = $this->s->handle("~~~RECURSIVE~~~", "", 0, new Doku_Handler());
64        $array = array("", array("~~~", "~~~"));
65        $this->assertEquals($r, $array);
66    }
67
68    /**
69     * Testing render method.
70     */
71    public function test_render() {
72        //test recursive inserting part of method with xhtml renderer
73        $r = new Doku_Renderer_xhtml();
74        $data = array("", array("~~~", "~~~"));
75        $result = $this->s->render("xhtml", $r, $data);
76        $this->assertEquals("<h4>Next link is recursively inserted.</h4>", $r->doc);
77        $this->assertTrue($result);
78
79        //test recursive inserting part of method with latex renderer
80        $r = new renderer_plugin_latexit();
81        $data = array("", array("~~~", "~~~"));
82        $result = $this->s->render("latex", $r, $data);
83        $this->assertTrue($result);
84
85        //test zotero of method
86        $data = "bibliography";
87        $result = $this->s->render("latex", $r, $data);
88        $this->assertEquals("\\cite{bibliography}", $r->doc);
89        $this->assertTrue($result);
90
91        //test with not implemented rendering mode
92        $result = $this->s->render("doc", $r, $data);
93        $this->assertFalse($result);
94    }
95
96}
97