Contao\CoreBundle\Test\Contao\ImageTest::testGetCacheName PHP Method

testGetCacheName() public method

Tests the getCacheName() method.
public testGetCacheName ( array $arguments, string $expectedCacheName )
$arguments array
$expectedCacheName string
    public function testGetCacheName($arguments, $expectedCacheName)
    {
        /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileMock */
        $fileMock = $this->getMockBuilder('Contao\\File')->setMethods(['__get', 'exists'])->setConstructorArgs(['dummy.jpg'])->getMock();
        $fileMock->expects($this->any())->method('exists')->will($this->returnValue(true));
        $fileMock->expects($this->any())->method('__get')->will($this->returnCallback(function ($key) use($arguments) {
            switch ($key) {
                case 'extension':
                    return 'jpg';
                case 'path':
                    return $arguments[2];
                case 'filename':
                    return $arguments[2];
                case 'mtime':
                    return $arguments[5];
                case 'width':
                case 'viewWidth':
                    return 200;
                case 'height':
                case 'viewHeight':
                    return 200;
                default:
                    return null;
            }
        }));
        $imageObj = new Image($fileMock);
        $imageObj->setTargetWidth($arguments[0]);
        $imageObj->setTargetHeight($arguments[1]);
        $imageObj->setResizeMode($arguments[3]);
        $imageObj->setZoomLevel($arguments[4]);
        $imageObj->setImportantPart($arguments[6]);
        $this->assertSame($imageObj->getCacheName(), $expectedCacheName);
    }