1<?php
2
3namespace dokuwiki\plugin\tagadd\test;
4
5use DokuWikiTest;
6use TestRequest;
7
8
9/**
10 * @group plugin_tagadd
11 * @group plugins
12 */
13class plugin_tagadd_ajax_test extends DokuWikiTest {
14
15    public function setup() {
16        $this->pluginsEnabled[] = 'tagadd';
17        $this->pluginsEnabled[] = 'ajaxedit';
18        $this->pluginsEnabled[] = 'tag';
19        $this->pluginsEnabled[] = 'tagfilter';
20        parent::setup();
21    }
22
23
24    public function test_basic_syntax() {
25        saveWikiText('test:plugin_tagadd',"Test\n{{tag>Tag1 Tag2}}",'test');
26
27        $data = rawWiki('test:plugin_tagadd');
28        $this->assertContains('{{tag>Tag1 Tag2}}', $data);
29
30        $request = new TestRequest();
31        $request->post([
32            'call'   => 'plugin_tagadd',
33            'action' => 'saveTags',
34            'pageid' => 'test:plugin_tagadd',
35            'form' => [
36                ['name' => 'tag', 'value' => 'Tag1'],
37                ['name' => 'tag', 'value' => 'Tag2'],
38                ['name' => 'tag', 'value' => 'Tag3'],
39            ],
40
41            'lastmod' => @filemtime(wikiFN('test:plugin_tagadd')),
42
43        ], '/lib/exe/ajax.php');
44
45        $data = rawWiki('test:plugin_tagadd');
46        $this->assertContains('{{tag> Tag1 Tag2 Tag3 }}', $data);
47
48        $request = new TestRequest();
49        $request->post([
50            'call'   => 'plugin_tagadd',
51            'action' => 'saveTags',
52            'pageid' => 'test:plugin_tagadd',
53            'form' => [
54                ['name' => 'tag', 'value' => 'Tag1'],
55            ],
56
57            'lastmod' => @filemtime(wikiFN('test:plugin_tagadd')),
58
59        ], '/lib/exe/ajax.php');
60
61
62        $data = rawWiki('test:plugin_tagadd');
63        $this->assertContains('{{tag> Tag1 }}', $data);
64    }
65}
66