3 * Tine 2.0 - http://www.tine20.org
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>
13 * Test class for Tinebase_Server_Plugin_Json
18 class Tinebase_Server_Plugin_JsonTests extends TestCase
21 * test with ContentType header set to application/json
23 public function testServerContentType()
25 $request = \Zend\Http\PhpEnvironment\Request::fromString(<<<EOS
26 POST /index.php HTTP/1.1\r
28 Content-Type: application/json\r
29 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7\r
33 $server = Tinebase_Core::getDispatchServer($request);
35 $this->assertInstanceOf('Tinebase_Server_Json', $server);
39 * test with ACCESS-CONTROL-REQUEST-METHOD header set
41 public function testServerCORSHeader()
43 $request = \Zend\Http\PhpEnvironment\Request::fromString(<<<EOS
44 OPTIONS /index.php HTTP/1.1\r
46 ACCESS-CONTROL-REQUEST-METHOD: application/json\r
47 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7\r
51 $server = Tinebase_Core::getDispatchServer($request);
53 $this->assertInstanceOf('Tinebase_Server_Json', $server);
57 * test with post parameter requestType set to JSON
59 public function testServerPostParameter()
61 $request = \Zend\Http\PhpEnvironment\Request::fromString(<<<EOS
62 POST /index.php?requestType=JSON HTTP/1.1\r
64 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120824 Thunderbird/15.0 Lightning/1.7\r
68 $request->setPost(new Zend\Stdlib\Parameters(array('requestType' => 'JSON')));
70 $server = Tinebase_Core::getDispatchServer($request);
72 $this->assertInstanceOf('Tinebase_Server_Json', $server);