Ejemplo n.º 1
0
 /**
  * Test for getContentType() method.
  *
  * @dataProvider providerContentType
  * @param string $contentTypeHeader 'Content-Type' header value
  * @param string $contentType Appropriate content type for header value
  * @param string|boolean $exceptionMessage \Exception message (boolean FALSE if exception is not expected)
  */
 public function testGetContentType($contentTypeHeader, $contentType, $exceptionMessage = false)
 {
     $this->_request->expects($this->once())->method('getHeader')->with('Content-Type')->will($this->returnValue($contentTypeHeader));
     try {
         $this->assertEquals($contentType, $this->_request->getContentType());
     } catch (\Magento\Framework\Exception\InputException $e) {
         if ($exceptionMessage) {
             $this->assertEquals($exceptionMessage, $e->getMessage(), 'Exception message does not match the expected one.');
             return;
         } else {
             $this->fail('Exception is thrown on valid header: ' . $e->getMessage());
         }
     }
     if ($exceptionMessage) {
         $this->fail('Expected exception was not raised.');
     }
 }