'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')); } /** * @test */ public function itIsPossibleToExtendTheContextBySignalSlot(): void { $view = new SimpleAttachmentTemplateView([ 'templateSource' => 'TollesTemplate! {testVar}', 'filenameEelExpression' => 'greet(testVar) + ".txt"', 'attachmentCharset' => false ]); $view->assign('testVar', 'WORLD'); $dispatcher = $this->objectManager->get(Dispatcher::class); $dispatcher->connect( SimpleAttachmentTemplateView::class, 'filenameEelExpressionContext', function (Context $eelContext) { $eelContext->push( function ($name) { return 'Hello ' . $name; }, 'greet' ); } ); $result = $view->render(); static::assertEquals( 'attachment; filename="Hello WORLD.txt"', $result->getHeaderLine('Content-Disposition') ); } }