|
@@ 126-157 (lines=32) @@
|
| 123 |
|
$this->client->request('GET', '/media/cache/resolve/invalid-filter/images/cats.jpeg'); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
public function testShouldResolveWithCustomFiltersPopulatingCacheFirst() |
| 127 |
|
{ |
| 128 |
|
/** @var Signer $signer */ |
| 129 |
|
$signer = self::$kernel->getContainer()->get('liip_imagine.cache.signer'); |
| 130 |
|
|
| 131 |
|
$params = array( |
| 132 |
|
'filters' => array( |
| 133 |
|
'thumbnail' => array('size' => array(50, 50)), |
| 134 |
|
), |
| 135 |
|
); |
| 136 |
|
|
| 137 |
|
$path = 'images/cats.jpeg'; |
| 138 |
|
|
| 139 |
|
$hash = $signer->sign($path, $params['filters']); |
| 140 |
|
|
| 141 |
|
$expectedCachePath = 'thumbnail_web_path/rc/'.$hash.'/'.$path; |
| 142 |
|
|
| 143 |
|
$url = 'http://localhost/media/cache/resolve/'.$expectedCachePath.'?'.http_build_query($params); |
| 144 |
|
|
| 145 |
|
//guard |
| 146 |
|
$this->assertFileNotExists($this->cacheRoot.'/'.$expectedCachePath); |
| 147 |
|
|
| 148 |
|
$this->client->request('GET', $url); |
| 149 |
|
|
| 150 |
|
$response = $this->client->getResponse(); |
| 151 |
|
|
| 152 |
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); |
| 153 |
|
$this->assertEquals(301, $response->getStatusCode()); |
| 154 |
|
$this->assertEquals('http://localhost/media/cache/'.$expectedCachePath, $response->getTargetUrl()); |
| 155 |
|
|
| 156 |
|
$this->assertFileExists($this->cacheRoot.'/'.$expectedCachePath); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
public function testShouldResolveWithCustomFiltersFromCache() |
| 160 |
|
{ |
|
@@ 159-192 (lines=34) @@
|
| 156 |
|
$this->assertFileExists($this->cacheRoot.'/'.$expectedCachePath); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
public function testShouldResolveWithCustomFiltersFromCache() |
| 160 |
|
{ |
| 161 |
|
/** @var Signer $signer */ |
| 162 |
|
$signer = self::$kernel->getContainer()->get('liip_imagine.cache.signer'); |
| 163 |
|
|
| 164 |
|
$params = array( |
| 165 |
|
'filters' => array( |
| 166 |
|
'thumbnail' => array('size' => array(50, 50)), |
| 167 |
|
), |
| 168 |
|
); |
| 169 |
|
|
| 170 |
|
$path = 'images/cats.jpeg'; |
| 171 |
|
|
| 172 |
|
$hash = $signer->sign($path, $params['filters']); |
| 173 |
|
|
| 174 |
|
$expectedCachePath = 'thumbnail_web_path/rc/'.$hash.'/'.$path; |
| 175 |
|
|
| 176 |
|
$url = 'http://localhost/media/cache/resolve/'.$expectedCachePath.'?'.http_build_query($params); |
| 177 |
|
|
| 178 |
|
$this->filesystem->dumpFile( |
| 179 |
|
$this->cacheRoot.'/'.$expectedCachePath, |
| 180 |
|
'anImageContent' |
| 181 |
|
); |
| 182 |
|
|
| 183 |
|
$this->client->request('GET', $url); |
| 184 |
|
|
| 185 |
|
$response = $this->client->getResponse(); |
| 186 |
|
|
| 187 |
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); |
| 188 |
|
$this->assertEquals(301, $response->getStatusCode()); |
| 189 |
|
$this->assertEquals('http://localhost/media/cache'.'/'.$expectedCachePath, $response->getTargetUrl()); |
| 190 |
|
|
| 191 |
|
$this->assertFileExists($this->cacheRoot.'/'.$expectedCachePath); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
public function testShouldResolvePathWithSpecialCharactersAndWhiteSpaces() |
| 195 |
|
{ |