1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\PagePartBundle\Tests\PagePartConfigurationReader; |
4
|
|
|
|
5
|
|
|
use Codeception\Test\Unit; |
6
|
|
|
use Kunstmaan\PagePartBundle\PageTemplate\PageTemplate; |
7
|
|
|
use Kunstmaan\PagePartBundle\PageTemplate\PageTemplateConfigurationParser; |
8
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
9
|
|
|
|
10
|
|
|
class PageTemplateConfigurationParserTest extends Unit |
11
|
|
|
{ |
12
|
|
|
public function testParseSf4Flow() |
13
|
|
|
{ |
14
|
|
|
$kernel = $this->makeEmpty(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->makeEmpty(KernelInterface::class, [ |
33
|
|
|
'locateResource' => __DIR__ . '/Resources/config/pagetemplates/test.yml', |
34
|
|
|
]); |
35
|
|
|
|
36
|
|
|
$pageTemplateConfigurationParser = new PageTemplateConfigurationParser($kernel, []); |
37
|
|
|
|
38
|
|
|
$result = $pageTemplateConfigurationParser->parse('MyWebsiteBundle:test'); |
39
|
|
|
$this->assertInstanceOf(PageTemplate::class, $result); |
40
|
|
|
$this->assertEquals('Test page', $result->getName()); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.