Elcodi\Bundle\MediaBundle\Tests\Functional\Controller\ImageResizeControllerTest::testResizeAction PHP Method

testResizeAction() public method

Test resize action.
public testResizeAction ( )
    public function testResizeAction()
    {
        /**
         * @var RouterInterface $router
         */
        $client = $this->createClient();
        $router = $this->get('router');
        $routeCollection = $router->getRouteCollection();
        $image = new UploadedFile(__DIR__ . '/images/image.png', 'image.png', 'image/png', 3966, null, true);
        $client->request('POST', $routeCollection->get('elcodi.route.image_upload')->getPath(), [], ['file' => $image]);
        $client->request('GET', $router->generate('elcodi.route.image_view', ['id' => 1, '_format' => 'json']));
        $responseView = $client->getResponse();
        $this->assertEquals(200, $responseView->getStatusCode());
        $this->assertEquals('image/png', $responseView->headers->get('content-type'));
        $this->assertNotEmpty($responseView->getContent());
        $client->request('GET', $router->generate('elcodi.route.image_resize', ['id' => 1, 'height' => 30, 'width' => 30, 'type' => 2, '_format' => 'json']));
        $responseResize = $client->getResponse();
        $this->assertEquals(200, $responseResize->getStatusCode());
        $this->assertEquals('image/jpeg', $responseResize->headers->get('content-type'));
        $this->assertNotEmpty($responseResize->getContent());
        $this->assertNotEquals($responseView->getContent(), $responseResize->getContent());
    }
ImageResizeControllerTest