/
action_handle.test.php
80 lines (64 loc) · 1.79 KB
/
action_handle.test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
use dokuwiki\plugin\sqlite\SQLiteDB;
/**
* @group plugin_data
* @group plugins
*/
class action_handle_test extends DokuWikiTest
{
protected $pluginsEnabled = array('data', 'sqlite');
protected $action;
/** @var helper_plugin_data */
protected $helper;
/** @var SQLiteDB */
protected $db;
public function tearDown(): void
{
parent::tearDown();
$this->db->exec('DELETE FROM pages WHERE page = ?', 'test');
}
public function setUp(): void
{
parent::setUp();
$this->action = new action_plugin_data();
$this->helper = plugin_load('helper', 'data');
$this->db = $this->helper->getDB();
$this->db->exec(
'INSERT INTO pages ( pid, page, title , class , lastmod) VALUES (?, ?, ?, ?, ?)',
[1, 'test', 'title', 'class', time()]
);
}
public function testHandleStillPresent()
{
$data = array(
0 => array(
1 => 'dataentry'
),
1 => '',
2 => 'test'
);
$event = new Doku_Event('', $data);
$this->action->handle($event, null);
$pid = $this->getTestPageId();
$this->assertFalse(!$pid);
}
public function testHandleDelete()
{
$data = array(
0 => array(
1 => 'no entry'
),
1 => '',
2 => 'test'
);
$event = new Doku_Event('', $data);
$this->action->handle($event, null);
$pid = $this->db->queryValue('SELECT pid FROM pages WHERE page = ?', 'test');
$this->assertTrue(!$pid);
}
private function getTestPageId()
{
$pid = (int) $this->db->queryValue('SELECT pid FROM pages WHERE page = ?', 'test');
return $pid;
}
}