2018-09-02 02:09:56 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-02 02:09:56 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
|
|
|
|
|
|
|
|
use Engelsystem\Http\Request;
|
|
|
|
use Engelsystem\Renderer\Twig\Extensions\Legacy;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
class LegacyTest extends ExtensionTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Legacy::getFunctions
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGetFunctions(): void
|
2018-09-02 02:09:56 +02:00
|
|
|
{
|
|
|
|
$isSafeHtml = ['is_safe' => ['html']];
|
|
|
|
/** @var Request|MockObject $request */
|
|
|
|
$request = $this->createMock(Request::class);
|
|
|
|
|
|
|
|
$extension = new Legacy($request);
|
|
|
|
$functions = $extension->getFunctions();
|
|
|
|
|
|
|
|
$this->assertExtensionExists('menu', 'make_navigation', $functions, $isSafeHtml);
|
|
|
|
$this->assertExtensionExists('menuUserShiftState', 'User_shift_state_render', $functions, $isSafeHtml);
|
|
|
|
$this->assertExtensionExists('menuUserHints', 'header_render_hints', $functions, $isSafeHtml);
|
2023-01-22 19:16:33 +01:00
|
|
|
$this->assertExtensionExists('menuLanguages', 'make_language_select', $functions, $isSafeHtml);
|
2018-09-02 02:09:56 +02:00
|
|
|
$this->assertExtensionExists('page', [$extension, 'getPage'], $functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Legacy::__construct
|
2019-04-24 11:01:37 +02:00
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Legacy::getPage
|
2018-09-02 02:09:56 +02:00
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testIsAuthenticated(): void
|
2018-09-02 02:09:56 +02:00
|
|
|
{
|
|
|
|
/** @var Request|MockObject $request */
|
|
|
|
$request = $this->createMock(Request::class);
|
|
|
|
|
|
|
|
$extension = new Legacy($request);
|
|
|
|
|
|
|
|
$request->expects($this->exactly(2))
|
|
|
|
->method('has')
|
|
|
|
->with('p')
|
|
|
|
->willReturnOnConsecutiveCalls(true, false);
|
|
|
|
|
|
|
|
$request->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->with('p')
|
|
|
|
->willReturn('foo-bar');
|
|
|
|
|
|
|
|
$request->expects($this->once())
|
|
|
|
->method('path')
|
|
|
|
->willReturn('batz');
|
|
|
|
|
|
|
|
$this->assertEquals('foo-bar', $extension->getPage());
|
|
|
|
$this->assertEquals('batz', $extension->getPage());
|
|
|
|
}
|
|
|
|
}
|