1<?php
2/**
3 * @group plugin_rowmove
4 * @group plugins
5 */
6class plugin_rowmove_ajax_test extends DokuWikiTest {
7
8    public function setup() {
9        $this->pluginsEnabled[] = 'rowmove';
10        $this->pluginsEnabled[] = 'ajaxedit';
11        parent::setup();
12    }
13
14
15    public function test_basic_syntax() {
16        global $INFO;
17        $INFO['id'] = 'test:plugin_rowmove:syntax';
18        $INFO['perm'] = AUTH_EDIT;
19        saveWikiText('test:plugin_rowmove:syntax',"|row1|<rowmove>|\n|row2|<rowmove>|\n",'test');
20
21        $xhtml = p_wiki_xhtml('test:plugin_rowmove:syntax');
22        $doc = phpQuery::newDocument($xhtml);
23
24        $this->assertEquals(pq("td",$doc)->get(0)->textContent, 'row1');
25        $this->assertEquals(pq("td",$doc)->get(2)->textContent, 'row2');
26
27        $request = new TestRequest();
28        $request->post([
29            'call'   => 'plugin_rowmove',
30            'pageid' => 'test:plugin_rowmove:syntax',
31            'id'     => 0,
32            'index'  => 0,
33            'idx_row' => 0,
34            'idx_row2' => 1,
35
36            'lastmod' => @filemtime(wikiFN('test:plugin_rowmove:syntax')),
37
38        ], '/lib/exe/ajax.php');
39
40        $xhtml = p_wiki_xhtml('test:plugin_rowmove:syntax');
41        $doc = phpQuery::newDocument($xhtml);
42
43        $selector = pq("span.rowmove",$doc);
44        $this->assertTrue($selector->length === 2);
45        $this->assertTrue(pq("img",$selector)->length === 4);
46
47        $this->assertEquals(pq("td",$doc)->get(0)->textContent, 'row2');
48        $this->assertEquals(pq("td",$doc)->get(2)->textContent, 'row1');
49    }
50}
51