0012688: Tinebase_FileSystem - fix clear deleted files
[tine20] / tests / tine20 / Tinebase / Server / Plugin / JsonTests.php
1 <?php
2 /**
3  * Tine 2.0 - http://www.tine20.org
4  * 
5  * @package     Tinebase
6  * @subpackage  Server
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
8  * @copyright   Copyright (c) 2015-2015 Metaways Infosystems GmbH (http://www.metaways.de)
9  * @author      Lars Kneschke <l.kneschke@metaways.de>
10  */
11
12 /**
13  * Test class for Tinebase_Server_Plugin_Json
14  * 
15  * @package     Tinebase
16  * @subpackage  Server
17  */
18 class Tinebase_Server_Plugin_JsonTests extends TestCase
19 {
20     /**
21      * test with ContentType header set to application/json
22      */
23     public function testServerContentType()
24     {
25         $request = \Zend\Http\PhpEnvironment\Request::fromString(
26             "POST /index.php HTTP/1.1\r\n".
27             "Host: localhost\r\n".
28             "Content-Type: application/json\r\n".
29             "User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7"
30         );
31         
32         $server = Tinebase_Core::getDispatchServer($request);
33         
34         $this->assertInstanceOf('Tinebase_Server_Json', $server);
35     }
36     
37     /**
38      * test with ACCESS-CONTROL-REQUEST-METHOD header set
39      */
40     public function testServerCORSHeader()
41     {
42         $request = \Zend\Http\PhpEnvironment\Request::fromString(
43             "POST /index.php HTTP/1.1\r\n".
44             "Host: localhost\r\n".
45             "ACCESS-CONTROL-REQUEST-METHOD: application/json\r\n".
46             "User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7"
47         );
48         
49         $server = Tinebase_Core::getDispatchServer($request);
50         
51         $this->assertInstanceOf('Tinebase_Server_Json', $server);
52     }
53     
54     /**
55      * test with post parameter requestType set to JSON
56      */
57     public function testServerPostParameter()
58     {
59         $request = \Zend\Http\PhpEnvironment\Request::fromString(
60             "POST /index.php?requestType=JSON HTTP/1.1\r\n".
61             "Host: localhost\r\n".
62             "User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7"
63         );
64         
65         $request->setPost(new Zend\Stdlib\Parameters(array('requestType' => 'JSON')));
66         
67         $server = Tinebase_Core::getDispatchServer($request);
68         
69         $this->assertInstanceOf('Tinebase_Server_Json', $server);
70     }
71 }