public function testRegister() { $xml = Mad_Controller_Mime_Type::lookupByExtension("iphone"); $this->assertNull($xml); Mad_Controller_Mime_Type::register('text/iphone', 'apl', array('text/phone'), array('aap')); $iphone = Mad_Controller_Mime_Type::lookup("text/iphone"); $this->assertNotNull($iphone); $iphone = Mad_Controller_Mime_Type::lookupByExtension("apl"); $this->assertNotNull($iphone); }
/** * Set the content type for this mock request. * * $contentType may be a type ("application/xml"), an * extension ("xml"), a Mad_Controller_Mime_Type, or NULL. * * $request->setContentType('application/xml'); // type * $request->setContentType('xml') // extension * * If you want to manipulate the content type header directly, * you need to call this method with NULL after setting the header * to wipe any previously cached value. See getContentType(). * * $request->setServer('CONTENT_TYPE', 'raw header value'); * $request->setContentType(null); * * @param mixed $contentType * @return void */ public function setContentType($contentType) { if (is_string($contentType)) { if (strpos($contentType, '/') !== false) { $contentType = Mad_Controller_Mime_Type::lookup($contentType); } else { $contentType = Mad_Controller_Mime_Type::lookupByExtension($contentType); } } $this->_contentType = $contentType; }
/** * Returns the Mime type for the format used in the request. If there is no * format available, the first of the * * @return string */ public function getFormat() { if (!isset($this->_format)) { $params = $this->getParameters(); if (isset($params['format'])) { $this->_format = Mad_Controller_Mime_Type::lookupByExtension($params['format']); } else { $this->_format = current($this->getAccepts()); } } return $this->_format; }