engelsystem/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php

38 lines
1.0 KiB
PHP
Raw Normal View History

2018-08-26 12:23:47 +02:00
<?php
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
use Engelsystem\Helpers\Authenticator;
use Engelsystem\Models\User\User;
2018-08-26 12:23:47 +02:00
use Engelsystem\Renderer\Twig\Extensions\Globals;
use PHPUnit\Framework\MockObject\MockObject;
2018-08-26 12:23:47 +02:00
class GlobalsTest extends ExtensionTest
{
/**
* @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()
{
/** @var Authenticator|MockObject $auth */
$auth = $this->createMock(Authenticator::class);
$user = new User();
2018-09-02 02:09:56 +02:00
$auth->expects($this->exactly(2))
->method('user')
->willReturnOnConsecutiveCalls(
null,
$user
);
$extension = new Globals($auth);
2018-09-02 02:09:56 +02:00
2018-08-26 12:23:47 +02:00
$globals = $extension->getGlobals();
$this->assertGlobalsExists('user', [], $globals);
$globals = $extension->getGlobals();
$this->assertGlobalsExists('user', $user, $globals);
2018-08-26 12:23:47 +02:00
}
}