xref: /dokuwiki/_test/tests/test/basic.test.php (revision 9894e7afaae16cc0699afbe839681e023afee65a)
1f8369d7dSTobias Sarnowski<?php
2f8369d7dSTobias Sarnowski
3f8369d7dSTobias Sarnowski/**
4f8369d7dSTobias Sarnowski * @group integration
5f8369d7dSTobias Sarnowski */
6f8369d7dSTobias Sarnowskiclass InttestsBasicTest extends DokuWikiTest {
7f8369d7dSTobias Sarnowski    /**
8f8369d7dSTobias Sarnowski     * Execute the simplest possible request and expect
9f8369d7dSTobias Sarnowski     * a dokuwiki page which obviously has the word "DokuWiki"
10f8369d7dSTobias Sarnowski     * in it somewhere.
11f8369d7dSTobias Sarnowski     */
12f8369d7dSTobias Sarnowski    function testSimpleRun() {
13f8369d7dSTobias Sarnowski        $request = new TestRequest();
14f8369d7dSTobias Sarnowski
15f8369d7dSTobias Sarnowski        $response = $request->execute();
16f8369d7dSTobias Sarnowski
17f8369d7dSTobias Sarnowski        $this->assertTrue(
18f8369d7dSTobias Sarnowski            strpos($response->getContent(), 'DokuWiki') >= 0,
19f8369d7dSTobias Sarnowski            'DokuWiki was not a word in the output'
20f8369d7dSTobias Sarnowski        );
21f8369d7dSTobias Sarnowski    }
229e777ceeSAndreas Gohr
239e777ceeSAndreas Gohr    function testPost() {
249e777ceeSAndreas Gohr        $request = new TestRequest();
259e777ceeSAndreas Gohr
269e777ceeSAndreas Gohr        $input = array(
279e777ceeSAndreas Gohr            'string' => 'A string',
289e777ceeSAndreas Gohr            'array'  => array(1, 2, 3),
299e777ceeSAndreas Gohr            'id'     => 'wiki:dokuwiki'
309e777ceeSAndreas Gohr        );
319e777ceeSAndreas Gohr
329e777ceeSAndreas Gohr        $response = $request->post($input);
339e777ceeSAndreas Gohr
349e777ceeSAndreas Gohr        // server var check
359e777ceeSAndreas Gohr        $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
369e777ceeSAndreas Gohr        $this->assertEquals('',$request->getServer('QUERY_STRING'));
379e777ceeSAndreas Gohr        $this->assertEquals('/doku.php',$request->getServer('REQUEST_URI'));
389e777ceeSAndreas Gohr
399e777ceeSAndreas Gohr        // variable setup check
409e777ceeSAndreas Gohr        $this->assertEquals('A string', $request->getPost('string'));
419e777ceeSAndreas Gohr        $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
429e777ceeSAndreas Gohr        $this->assertEquals('wiki:dokuwiki', $request->getPost('id'));
439e777ceeSAndreas Gohr
449e777ceeSAndreas Gohr        // output check
459e777ceeSAndreas Gohr        $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
469e777ceeSAndreas Gohr    }
479e777ceeSAndreas Gohr
489e777ceeSAndreas Gohr    function testPostGet() {
499e777ceeSAndreas Gohr        $request = new TestRequest();
509e777ceeSAndreas Gohr
519e777ceeSAndreas Gohr        $input = array(
529e777ceeSAndreas Gohr            'string' => 'A string',
539e777ceeSAndreas Gohr            'array'  => array(1, 2, 3),
549e777ceeSAndreas Gohr        );
559e777ceeSAndreas Gohr
569e777ceeSAndreas Gohr        $response = $request->post($input,'/doku.php?id=wiki:dokuwiki');
579e777ceeSAndreas Gohr
589e777ceeSAndreas Gohr        // server var check
599e777ceeSAndreas Gohr        $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
609e777ceeSAndreas Gohr        $this->assertEquals('?id=wiki:dokuwiki',$request->getServer('QUERY_STRING'));
619e777ceeSAndreas Gohr        $this->assertEquals('/doku.php?id=wiki:dokuwiki',$request->getServer('REQUEST_URI'));
629e777ceeSAndreas Gohr
639e777ceeSAndreas Gohr        // variable setup check
649e777ceeSAndreas Gohr        $this->assertEquals('A string', $request->getPost('string'));
659e777ceeSAndreas Gohr        $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
669e777ceeSAndreas Gohr        $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
679e777ceeSAndreas Gohr
689e777ceeSAndreas Gohr        // output check
699e777ceeSAndreas Gohr        $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
709e777ceeSAndreas Gohr    }
719e777ceeSAndreas Gohr
729e777ceeSAndreas Gohr    function testGet() {
739e777ceeSAndreas Gohr        $request = new TestRequest();
749e777ceeSAndreas Gohr
759e777ceeSAndreas Gohr        $input = array(
769e777ceeSAndreas Gohr            'string' => 'A string',
779e777ceeSAndreas Gohr            'array'  => array(1, 2, 3),
789e777ceeSAndreas Gohr            'test'   => 'bar'
799e777ceeSAndreas Gohr        );
809e777ceeSAndreas Gohr
819e777ceeSAndreas Gohr        $response = $request->get($input,'/doku.php?id=wiki:dokuwiki&test=foo');
829e777ceeSAndreas Gohr
839e777ceeSAndreas Gohr        // server var check
849e777ceeSAndreas Gohr        $this->assertEquals('GET',$request->getServer('REQUEST_METHOD'));
859e777ceeSAndreas Gohr        $this->assertEquals(
869e777ceeSAndreas Gohr            '?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
879e777ceeSAndreas Gohr            $request->getServer('QUERY_STRING')
889e777ceeSAndreas Gohr        );
899e777ceeSAndreas Gohr        $this->assertEquals(
909e777ceeSAndreas Gohr            '/doku.php?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
919e777ceeSAndreas Gohr            $request->getServer('REQUEST_URI')
929e777ceeSAndreas Gohr        );
939e777ceeSAndreas Gohr
949e777ceeSAndreas Gohr        // variable setup check
959e777ceeSAndreas Gohr        $this->assertEquals('A string', $request->getGet('string'));
969e777ceeSAndreas Gohr        $this->assertEquals(array(1, 2, 3), $request->getGet('array'));
979e777ceeSAndreas Gohr        $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
989e777ceeSAndreas Gohr        $this->assertEquals('bar', $request->getGet('test'));
999e777ceeSAndreas Gohr
1009e777ceeSAndreas Gohr        // output check
1019e777ceeSAndreas Gohr        $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
1029e777ceeSAndreas Gohr    }
1039e777ceeSAndreas Gohr
104*9894e7afSChristopher Smith    function testScripts() {
105*9894e7afSChristopher Smith        $request = new TestRequest();
106*9894e7afSChristopher Smith
107*9894e7afSChristopher Smith        // doku
108*9894e7afSChristopher Smith        $response = $request->get();
109*9894e7afSChristopher Smith        $this->assertEquals('doku.php',$request->getScript());
110*9894e7afSChristopher Smith
111*9894e7afSChristopher Smith        $response = $request->get(array(),'/doku.php?id=wiki:dokuwiki&test=foo');
112*9894e7afSChristopher Smith        $this->assertEquals('doku.php',$request->getScript());
113*9894e7afSChristopher Smith
114*9894e7afSChristopher Smith        // fetch
115*9894e7afSChristopher Smith        $response = $request->get(array(),'/lib/exe/fetch.php?media=wiki:dokuwiki-128.png');
116*9894e7afSChristopher Smith        $this->assertEquals('lib/exe/fetch.php',$request->getScript());
117*9894e7afSChristopher Smith
118*9894e7afSChristopher Smith        // detail
119*9894e7afSChristopher Smith        $response = $request->get(array(),'/lib/exe/detail.php?id=start&media=wiki:dokuwiki-128.png');
120*9894e7afSChristopher Smith        $this->assertEquals('lib/exe/detail.php',$request->getScript());
121*9894e7afSChristopher Smith    }
1229e777ceeSAndreas Gohr
123f8369d7dSTobias Sarnowski}
124