DigiComp.AttachmentViewUtility/Tests/Functional/AttachmentViewTraitTest.php
Ferdinand Kuhl e8bead891a
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/functional-tests Pipeline was successful
Initial version
2023-10-17 18:49:19 +02:00

49 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace DigiComp\AttachmentViewUtility\Tests\Functional;
use DigiComp\AttachmentViewUtility\Tests\Functional\Fixtures\SimpleAttachmentTemplateView;
use Neos\Flow\Tests\FunctionalTestCase;
use Psr\Http\Message\ResponseInterface;
class AttachmentViewTraitTest extends FunctionalTestCase
{
/**
* @test
*/
public function itCreatesAttachmentResponses(): void
{
$view = new SimpleAttachmentTemplateView([
'templateSource' => 'TollesTemplate! {testVar}',
'filenameEelExpression' => 'testVar + ".txt"',
'attachmentCharset' => 'iso-8859-1'
]);
$view->assign('testVar', '£ and € rates');
$result = $view->render();
static::assertInstanceOf(ResponseInterface::class, $result);
static::assertEquals(
'attachment; filename="£ and ? rates.txt"; filename*=UTF-8\'\'%C2%A3%20and%20%E2%82%AC%20rates.txt',
$result->getHeaderLine('Content-Disposition')
);
static::assertEquals('text/plain; charset=iso-8859-1', $result->getHeaderLine('Content-Type'));
static::assertEquals('TollesTemplate! £ and € rates', (string)$result->getBody());
}
/**
* @test
*/
public function itIsPossibleToSuppressCharset(): void
{
$view = new SimpleAttachmentTemplateView([
'templateSource' => 'TollesTemplate! {testVar}',
'filenameEelExpression' => 'testVar + ".txt"',
'attachmentCharset' => false
]);
$view->assign('testVar', 'WORLD');
$result = $view->render();
static::assertEquals('text/plain', $result->getHeaderLine('Content-Type'));
}
}