ImboUnitTest\Http\Response\ResponseFormatterTest::testUsesTheOriginalMimeTypeOfTheImageIfConfigDisablesContentNegotiationForImages PHP Метод

testUsesTheOriginalMimeTypeOfTheImageIfConfigDisablesContentNegotiationForImages() публичный Метод

    public function testUsesTheOriginalMimeTypeOfTheImageIfConfigDisablesContentNegotiationForImages($originalMimeType, $expectedFormatter)
    {
        // Use a real object since the code we are testing uses get_class(), which won't work as
        // expected when the object used is a mock
        $image = new Image();
        $image->setMimeType($originalMimeType);
        $requestHeaders = $this->getMock('Symfony\\Component\\HttpFoundation\\HeaderBag');
        $this->request->headers = $requestHeaders;
        $this->contentNegotiation->expects($this->any())->method('isAcceptable')->will($this->returnValue(1));
        $this->response->expects($this->never())->method('setVary');
        $this->response->expects($this->once())->method('getModel')->will($this->returnValue($image));
        $event = $this->getMock('Imbo\\EventManager\\Event');
        $event->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
        $event->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
        $event->expects($this->any())->method('getConfig')->will($this->returnValue(['contentNegotiateImages' => false]));
        $this->responseFormatter->negotiate($event);
        $this->assertSame($expectedFormatter, $this->responseFormatter->getFormatter());
    }