示例#1
0
 public function testGetContentType()
 {
     //Case A
     $_SERVER['CONTENT_TYPE'] = 'application/json';
     $r1 = new Slim_Http_Request();
     $this->assertEquals($_SERVER['CONTENT_TYPE'], $r1->getContentType());
     //Case B
     unset($_SERVER['CONTENT_TYPE']);
     $r2 = new Slim_Http_Request();
     $this->assertEquals('application/x-www-form-urlencoded', $r2->getContentType());
     //Case C
     $_SERVER['CONTENT_TYPE'] = 'text/html; charset=ISO-8859-4';
     $r3 = new Slim_Http_Request();
     $this->assertEquals('text/html', $r3->getContentType());
 }
示例#2
0
 /**
  * Test get content type
  */
 public function testGetContentTypeWhenNotExists()
 {
     $env = Slim_Environment::mock();
     $req = new Slim_Http_Request($env);
     $this->assertNull($req->getContentType());
 }
示例#3
0
文件: RequestTest.php 项目: ntdt/Slim
 public function testGetContentType() {
     //Case A
     $_SERVER['CONTENT_TYPE'] = 'application/json';
     $r = new Slim_Http_Request();
     $this->assertEquals($_SERVER['CONTENT_TYPE'], $r->getContentType());
     //Case B
     unset($_SERVER['CONTENT_TYPE']);
     $r = new Slim_Http_Request();
     $this->assertEquals('application/x-www-form-urlencoded', $r->getContentType());
 }