-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
AbstractFusionObjectTest.php
75 lines (67 loc) · 2.36 KB
/
AbstractFusionObjectTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Neos\Fusion\Tests\Functional\FusionObjects;
/*
* This file is part of the Neos.Fusion package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use GuzzleHttp\Psr7\ServerRequest;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Tests\FunctionalTestCase;
use Neos\Fusion\Core\FusionGlobals;
use Neos\Fusion\Core\FusionSourceCodeCollection;
use Neos\Fusion\Core\RuntimeFactory;
/**
* Testcase for the Fusion View
*
*/
abstract class AbstractFusionObjectTest extends FunctionalTestCase
{
/**
* @var ActionRequest
*/
protected $request;
protected function buildView(): TestingViewForFusionRuntime
{
$this->request = ActionRequest::fromHttpRequest(new ServerRequest('GET', 'http://localhost/'));
$runtime = $this->objectManager->get(RuntimeFactory::class)->createFromSourceCode(
FusionSourceCodeCollection::fromFilePath(__DIR__ . '/Fixtures/Fusion/Root.fusion'),
FusionGlobals::fromArray(['request' => $this->request])
);
$view = new TestingViewForFusionRuntime($runtime);
$view->assign('fixtureDirectory', __DIR__ . '/Fixtures/');
return $view;
}
/**
* Used for Fusion objects / Eel and plain value interoperability testing.
* Renders Fusions in the following paths and expects given $expected as result each time:
* $basePath . 'Fusion'
* $basePath . 'Eel'
* $basePath . 'PlainValue'
*
* @param string $expected
* @param string $basePath
*/
protected function assertMultipleFusionPaths($expected, $basePath)
{
$this->assertFusionPath($expected, $basePath . 'Eel');
$this->assertFusionPath($expected, $basePath . 'PlainValue');
$this->assertFusionPath($expected, $basePath . 'Fusion');
}
/**
* Renders the given Fusion path and asserts that the result is the same es the given expected.
*
* @param string $expected
* @param string $path
*/
protected function assertFusionPath($expected, $path)
{
$view = $this->buildView();
$view->setFusionPath($path);
self::assertSame($expected, $view->render(), 'Fusion at path "' . $path . '" produced wrong results.');
}
}