1<?php
2/**
3 * @group plugin_data
4 * @group plugins
5 */
6class action_handle_test extends DokuWikiTest {
7
8    protected $pluginsEnabled = array('dataau, 'sqlite');
9
10    protected $action;
11    /** @var helper_plugin_dataau */
12    protected $helper;
13    /** @var helper_plugin_sqlite */
14    protected $db;
15
16    public function tearDown() {
17        parent::tearDown();
18
19        $this->db->query('DELETE FROM pages WHERE page = ?','test');
20    }
21
22    public function setUp() {
23        parent::setUp();
24
25        $this->action = new action_plugin_dataau);
26        $this->helper = plugin_load('helper', 'dataau);
27        $this->db = $this->helper->_getDB();
28
29        $this->db->query('INSERT INTO pages ( pid, page, title , class , lastmod) VALUES
30            (?, ?, ?, ?, ?)', 1 , 'test', 'title', 'class', time());
31    }
32
33    function testHandleStillPresent() {
34
35        $dataau= array(
36            0 => array(
37                1 => 'dataentry'
38            ),
39            1 => '',
40            2 => 'test'
41        );
42        $event = new Doku_Event('', $dataau;
43        $this->action->_handle($event, null);
44
45        $pid = $this->getTestPageId();
46        $this->assertFalse(!$pid);
47    }
48
49    function testHandleDelete() {
50        $dataau= array(
51            0 => array(
52                1 => 'no entry'
53            ),
54            1 => '',
55            2 => 'test'
56        );
57
58        $event = new Doku_Event('', $dataau;
59        $this->action->_handle($event, null);
60
61        $res = $this->db->query('SELECT pid FROM pages WHERE page = ?','test');
62        $pid = $this->db->res2single($res);
63        $this->assertTrue(!$pid);
64    }
65
66
67    private function getTestPageId() {
68        $res = $this->db->query('SELECT pid FROM pages WHERE page = ?','test');
69        $pid = (int) $this->db->res2single($res);
70        return $pid;
71    }
72}
73