1<?php
2
3/**
4 * Action tests for the latexit plugin
5 *
6 * @group plugin_latexit
7 * @group plugins
8 */
9class action_plugin_latexit_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    /**
18     * Variable to store the instance of action plugin.
19     * @var action_plugin_latexit
20     */
21    protected $a;
22
23    /**
24     * Prepares the testing environment.
25     */
26    public function setUp() {
27        parent::setUp();
28
29        $this->a = new action_plugin_latexit();
30    }
31
32    /**
33     * Testing _purgeCache method.
34     * Checks, if the access time to conf file is newer or equal the current time.
35     */
36    public function test__purgeCache() {
37        //create object from array, so it can be accessed via -> operator
38        $data = array("mode" => "latexit");
39        $data = (object) $data;
40        //create new event
41        $e = new Doku_Event("event", $data);
42        //save current time
43        $time = time();
44        $this->a->_purgeCache($e, "");
45        //get last access time
46        $access_time = fileatime(DOKU_INC . 'conf/local.php');
47        //test
48        $this->assertGreaterThanOrEqual($time, $access_time);
49    }
50
51    /**
52     * Testing _setLatexitSort method.
53     * @global array $_GET Global var to simulate normal DW behaviour.
54     */
55    public function test__setLatexitSort() {
56        //prepare the environment
57        global $_GET;
58        $_GET["do"] = 'export_latexit';
59        //prepare the event object
60        $data = array("mode" => "latexit");
61        $data = (object) $data;
62        $e = new Doku_Event("event", $data);
63        $this->a->_setLatexitSort($e, "");
64        //this has to be tested through the involved syntax plugin
65        $syntax_plugin = plugin_load('syntax', 'latexit_base');
66        //test
67        $this->assertEquals(1, $syntax_plugin->getSort());
68    }
69
70}
71