1<?php
2/**
3 * @group plugin_const
4 * @group plugins
5 */
6class plugin_const_include_support_test extends DokuWikiTest {
7
8    public function setup() {
9        $this->pluginsEnabled[] = 'const';
10        $this->pluginsEnabled[] = 'include';
11        $this->_createPages();
12        parent::setup();
13    }
14
15    public function test_basic_sectionfix() {
16        $request = new TestRequest();
17        $response = $request->get(array('id' => 'test:plugin_const:start'), '/doku.php');
18
19        $first_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(0)->attr('value');
20        $second_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(1)->attr('value');
21        $third_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(2)->attr('value');
22
23        $this->assertEquals('57-87',  $first_sec);
24        $this->assertEquals('88-118', $second_sec);
25        $this->assertEquals('119-',   $third_sec);
26    }
27
28    public function test_include_sectionfix() {
29        $request = new TestRequest();
30        $response = $request->get(array('id' => 'test:plugin_const:include'), '/doku.php');
31
32        $section = array();
33
34        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(0)->attr('value');
35        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(1)->attr('value');
36        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(2)->attr('value');
37        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(3)->attr('value');
38        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(4)->attr('value');
39        $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(5)->attr('value');
40
41        $this->assertEquals('71-101',  $section[0]);
42        $this->assertEquals('57-87',   $section[1]);
43        $this->assertEquals('88-118',  $section[2]);
44        $this->assertEquals('119-',    $section[3]);
45        $this->assertEquals('102-141', $section[4]);
46        $this->assertEquals('142-',    $section[5]);
47    }
48
49    private function _createPages() {
50        saveWikiText('test:plugin_const:include',
51            '<const>'.DOKU_LF
52            .'var1=test:plugin_const:start'.DOKU_LF
53            .'var2=123456789123456789'.DOKU_LF
54            .'</const>'.DOKU_LF
55            .'====== Header1 ======'.DOKU_LF
56            .'%%var2%%'.DOKU_LF
57            .'====== Header2 ======'.DOKU_LF
58            .'{{page>%%var1%%}}'.DOKU_LF
59            .'====== Header3 ======'.DOKU_LF,
60            'setup for test');
61        saveWikiText('test:plugin_const:start',
62            '<const>'.DOKU_LF
63            .'var1=123456789'.DOKU_LF
64            .'var2=123456789123456789'.DOKU_LF
65            .'</const>'.DOKU_LF
66            .'====== Header1 ======'.DOKU_LF
67            .'%%var2%%'.DOKU_LF
68            .'====== Header2 ======'.DOKU_LF
69            .'%%var2%%'.DOKU_LF
70            .'====== Header3 ======'.DOKU_LF,
71            'setup for test');
72    }
73
74}
75