tests/IntegrationTests/POData/Misc/MiscTest.php
/**
	 * Test content type of primitive value
	 */
Test content type of primitive value
Test content type of primitive value
function testContentType_Count_Value()
	{
        $ch = curl_init();
        $headers = array();
        curl_setopt($ch, CURLOPT_URL, self::BASE_SERIVE_URL . '/Customers/$count');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        $this->assertTrue(array_key_exists('content_type', $info));
        $this->assertEquals($info['content_type'], 'text/plain;charset=utf-8');
         in json format, this iwll cause service to thow error
        $ch = curl_init();
        $headers = array(ODataConstants::HTTP_REQUEST_ACCEPT .':'. MimeTypes::MIME_APPLICATION_JSON);
        curl_setopt($ch, CURLOPT_URL, self::BASE_SERIVE_URL . '/Customers/$count');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        $pos = strpos($result, '"value": "Unsupported media type requested."');
        $this->assertTrue($pos !== false);
        $this->assertTrue(array_key_exists('content_type', $info));
        $this->assertEquals($info['content_type'], 'application/json');
         in atom format, this iwll cause service to thow error
        $ch = curl_init();
        $headers = array(ODataConstants::HTTP_REQUEST_ACCEPT .':'. MimeTypes::MIME_APPLICATION_ATOM);
        curl_setopt($ch, CURLOPT_URL, self::BASE_SERIVE_URL . '/Customers/$count');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        $pos = strpos($result, '<message>Unsupported media type requested.</message>');
        $this->assertTrue($pos !== false);
        $this->assertTrue(array_key_exists('content_type', $info));
        $this->assertEquals($info['content_type'], 'application/xml');
	}
function testContentType_Count_Value ( ) { $ ch = curl_init ( ) ; $ headers = array ( ) ; curl_setopt ( $ ch , CURLOPT_URL , self :: BASE_SERIVE_URL . '/Customers/$count' ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; $ result = curl_exec ( $ ch ) ; $ info = curl_getinfo ( $ ch ) ; curl_close ( $ ch ) ; $ this -> assertTrue ( array_key_exists ( 'content_type' , $ info ) ) ; $ this -> assertEquals ( $ info [ 'content_type' ] , 'text/plain;charset=utf-8' ) ; $ ch = curl_init ( ) ; $ headers = array ( ODataConstants :: HTTP_REQUEST_ACCEPT . ':' . MimeTypes :: MIME_APPLICATION_JSON ) ; curl_setopt ( $ ch , CURLOPT_URL , self :: BASE_SERIVE_URL . '/Customers/$count' ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; $ result = curl_exec ( $ ch ) ; $ info = curl_getinfo ( $ ch ) ; curl_close ( $ ch ) ; $ pos = strpos ( $ result , '"value": "Unsupported media type requested."' ) ; $ this -> assertTrue ( $ pos !== false ) ; $ this -> assertTrue ( array_key_exists ( 'content_type' , $ info ) ) ; $ this -> assertEquals ( $ info [ 'content_type' ] , 'application/json' ) ; $ ch = curl_init ( ) ; $ headers = array ( ODataConstants :: HTTP_REQUEST_ACCEPT . ':' . MimeTypes :: MIME_APPLICATION_ATOM ) ; curl_setopt ( $ ch , CURLOPT_URL , self :: BASE_SERIVE_URL . '/Customers/$count' ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; $ result = curl_exec ( $ ch ) ; $ info = curl_getinfo ( $ ch ) ; curl_close ( $ ch ) ; $ pos = strpos ( $ result , '<message>Unsupported media type requested.</message>' ) ; $ this -> assertTrue ( $ pos !== false ) ; $ this -> assertTrue ( array_key_exists ( 'content_type' , $ info ) ) ; $ this -> assertEquals ( $ info [ 'content_type' ] , 'application/xml' ) ; }
Test content type of primitive value
Test content type of primitive value
// Request for count // Request for count in json format, this iwll cause service to thow error // Should get error message for unsupported media type in json format // Request for count in atom format, this iwll cause service to thow error // Should get error message for unsupported media type in json format