2018-08-26 12:23:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
|
|
|
|
|
2018-10-08 19:30:37 +02:00
|
|
|
use Engelsystem\Helpers\Authenticator;
|
2020-11-15 18:47:30 +01:00
|
|
|
use Engelsystem\Http\Request;
|
2018-10-08 19:30:37 +02:00
|
|
|
use Engelsystem\Models\User\User;
|
2018-08-26 12:23:47 +02:00
|
|
|
use Engelsystem\Renderer\Twig\Extensions\Globals;
|
2018-10-08 19:30:37 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-08-26 12:23:47 +02:00
|
|
|
|
|
|
|
class GlobalsTest extends ExtensionTest
|
|
|
|
{
|
|
|
|
/**
|
2018-10-08 19:30:37 +02:00
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Globals::__construct
|
2018-08-26 12:23:47 +02:00
|
|
|
* @covers \Engelsystem\Renderer\Twig\Extensions\Globals::getGlobals
|
|
|
|
*/
|
|
|
|
public function testGetGlobals()
|
|
|
|
{
|
2018-10-08 19:30:37 +02:00
|
|
|
/** @var Authenticator|MockObject $auth */
|
|
|
|
$auth = $this->createMock(Authenticator::class);
|
2020-11-15 18:47:30 +01:00
|
|
|
/** @var Request|MockObject $request */
|
|
|
|
$request = $this->createMock(Request::class);
|
2018-10-08 19:30:37 +02:00
|
|
|
$user = new User();
|
2018-09-02 02:09:56 +02:00
|
|
|
|
2018-10-08 19:30:37 +02:00
|
|
|
$auth->expects($this->exactly(2))
|
|
|
|
->method('user')
|
|
|
|
->willReturnOnConsecutiveCalls(
|
|
|
|
null,
|
|
|
|
$user
|
|
|
|
);
|
|
|
|
|
2020-11-15 18:47:30 +01:00
|
|
|
$extension = new Globals($auth, $request);
|
2018-09-02 02:09:56 +02:00
|
|
|
|
2018-08-26 12:23:47 +02:00
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$this->assertGlobalsExists('user', [], $globals);
|
2020-11-15 18:47:30 +01:00
|
|
|
$this->assertGlobalsExists('request', $request, $globals);
|
2018-08-26 12:23:47 +02:00
|
|
|
|
|
|
|
$globals = $extension->getGlobals();
|
2018-10-08 19:30:37 +02:00
|
|
|
$this->assertGlobalsExists('user', $user, $globals);
|
2018-08-26 12:23:47 +02:00
|
|
|
}
|
|
|
|
}
|