|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
Deprecation Notice: Class Knp\Bundle\SnappyBundle\Tests\Snappy\LoggableGeneratorTest located in ./vendor/knplabs/knp-snappy-bundle/Tests/Snappy/Generator/LoggableGeneratorTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 |
|
5
|
|
|
Deprecation Notice: Class Knp\Bundle\SnappyBundle\DependencyInjection\ConfigurationTest located in ./vendor/knplabs/knp-snappy-bundle/Tests/DependencyInjection/ConfigurationTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 |
|
6
|
|
|
|
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Knp\Bundle\SnappyBundle\Tests\Response\Snappy; |
|
10
|
|
|
|
|
11
|
|
|
use Knp\Bundle\SnappyBundle\Snappy\Response\JpegResponse; |
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
|
13
|
|
|
|
|
14
|
|
|
class JpegResponseTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testDefaultParameters() |
|
17
|
|
|
{ |
|
18
|
|
|
$response = new JpegResponse('some_binary_output'); |
|
19
|
|
|
|
|
20
|
|
|
$this->assertSame(200, $response->getStatusCode()); |
|
21
|
|
|
$this->assertSame('some_binary_output', $response->getContent()); |
|
22
|
|
|
$this->assertSame('image/jpg', $response->headers->get('Content-Type')); |
|
23
|
|
|
$this->assertSame('inline; filename=output.jpg', str_replace('"', '', $response->headers->get('Content-Disposition'))); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testSetDifferentMimeType() |
|
27
|
|
|
{ |
|
28
|
|
|
$response = new JpegResponse('some_binary_output', 'test.jpg', 'application/octet-stream'); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertSame('application/octet-stream', $response->headers->get('Content-Type')); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testSetDifferentFileName() |
|
34
|
|
|
{ |
|
35
|
|
|
$fileName = 'test.jpg'; |
|
36
|
|
|
$response = new JpegResponse('some_binary_output', $fileName); |
|
37
|
|
|
$fileNameFromDispositionRegex = '/.*filename=([^"]+)/'; |
|
38
|
|
|
|
|
39
|
|
|
$this->assertSame(1, preg_match($fileNameFromDispositionRegex, str_replace('"', '', $response->headers->get('Content-Disposition')), $matches), 1); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertSame($fileName, $matches[1]); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|