summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-23 19:13:19 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-23 20:11:37 +0200
commit66038eda14d5d4e624b6636a6156570e3e940e49 (patch)
tree6e4b7557b7d91786ef47f22f7ddef85eed1dfb42 /tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php
parent590adffa9316b98544cb8d67b03b80e44ba9c8b7 (diff)
parent9d34f371cb9c5ab0d60bd3158678b9cc9da6cc80 (diff)
Merge branch 'twig-templates'
Diffstat (limited to 'tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php')
-rw-r--r--tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php b/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php
index 6cc3a4da..cdd9cd2a 100644
--- a/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php
+++ b/tests/Unit/Renderer/Twig/Extensions/GlobalsTest.php
@@ -2,24 +2,54 @@
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
+use Carbon\Carbon;
use Engelsystem\Renderer\Twig\Extensions\Globals;
+use PHPUnit\Framework\MockObject\MockObject;
class GlobalsTest extends ExtensionTest
{
/**
* @covers \Engelsystem\Renderer\Twig\Extensions\Globals::getGlobals
+ * @covers \Engelsystem\Renderer\Twig\Extensions\Globals::filterEventConfig
*/
public function testGetGlobals()
{
- $extension = new Globals();
+ global $user;
+ $user = [];
+
+ /** @var Globals|MockObject $extension */
+ $extension = $this->getMockBuilder(Globals::class)
+ ->setMethods(['getEventConfig'])
+ ->getMock();
+
+ $extension->expects($this->exactly(2))
+ ->method('getEventConfig')
+ ->willReturnOnConsecutiveCalls(
+ null,
+ [
+ 'lorem' => 'ipsum',
+ 'event_end_date' => 1234567890,
+ ]
+ );
+
$globals = $extension->getGlobals();
$this->assertGlobalsExists('user', [], $globals);
+ $this->assertGlobalsExists('event_config', [], $globals);
- global $user;
$user['foo'] = 'bar';
$globals = $extension->getGlobals();
$this->assertGlobalsExists('user', ['foo' => 'bar'], $globals);
+ $this->assertGlobalsExists('event_config', ['lorem' => 'ipsum'], $globals);
+
+ $config = $globals['event_config'];
+ $this->assertArrayHasKey('event_end_date', $config);
+ /** @var Carbon $eventEndDate */
+ $eventEndDate = $config['event_end_date'];
+ $this->assertInstanceOf(Carbon::class, $eventEndDate);
+
+ $eventEndDate->setTimezone('UTC');
+ $this->assertEquals('2009-02-13 23:31:30', $eventEndDate->format('Y-m-d H:i:s'));
}
}