Completed
Pull Request — 5.1 (#2266)
by
unknown
12:07
created

PageTemplateConfigurationParserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 36.36 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 12
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testParseSf4Flow() 0 17 1
A testParseSf3Flow() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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