1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\PagePartBundle\Tests\PagePartConfigurationReader; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\PagePartBundle\PageTemplate\PageTemplate; |
6
|
|
|
use Kunstmaan\PagePartBundle\PageTemplate\PageTemplateConfigurationParser; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
9
|
|
|
|
10
|
|
|
class PageTemplateConfigurationParserTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
public function testParseSf4Flow() |
13
|
|
|
{ |
14
|
|
|
$kernel = $this->createMock(KernelInterface::class); |
15
|
|
|
$pageTemplateConfigurationParser = new PageTemplateConfigurationParser($kernel, [ |
|
|
|
|
16
|
|
|
'contentpage' => [ |
17
|
|
|
'name' => 'Content page', |
18
|
|
|
'rows' => [ |
19
|
|
|
['regions' => [['name' => 'main', 'span' => 12]]], |
20
|
|
|
], |
21
|
|
|
'template' => 'Pages\\ContentPage\\pagetemplate.html.twig', |
22
|
|
|
], |
23
|
|
|
]); |
24
|
|
|
|
25
|
|
|
$result = $pageTemplateConfigurationParser->parse('contentpage'); |
26
|
|
|
$this->assertInstanceOf(PageTemplate::class, $result); |
27
|
|
|
$this->assertEquals('Content page', $result->getName()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
View Code Duplication |
public function testParseSf3Flow() |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$kernel = $this->createMock(KernelInterface::class); |
33
|
|
|
$kernel->method('locateResource')->willReturn(__DIR__ . '/Resources/config/pagetemplates/test.yml'); |
34
|
|
|
|
35
|
|
|
$pageTemplateConfigurationParser = new PageTemplateConfigurationParser($kernel, []); |
|
|
|
|
36
|
|
|
|
37
|
|
|
$result = $pageTemplateConfigurationParser->parse('MyWebsiteBundle:test'); |
38
|
|
|
$this->assertInstanceOf(PageTemplate::class, $result); |
39
|
|
|
$this->assertEquals('Test page', $result->getName()); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: