Completed
Push — 6.0 ( eb641c...92cb73 )
by Ruud
148:12 queued 131:31
created

DomainConfigurationTest::getContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
namespace Kunstmaan\AdminListBundle\Tests\Helper;
4
5
use Kunstmaan\AdminBundle\Helper\DomainConfiguration;
6
use PHPUnit_Framework_TestCase;
7
use Symfony\Component\DependencyInjection\Container;
8
use Symfony\Component\HttpFoundation\Request;
9
10
/**
11
 * Generated by PHPUnit_SkeletonGenerator on 2015-03-19 at 09:56:53.
12
 */
13
class DomainConfigurationTest extends PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * @var DomainConfiguration
17
     */
18
    protected $object;
19
20
    /**
21
     * Sets up the fixture, for example, opens a network connection.
22
     * This method is called before a test is executed.
23
     */
24 View Code Duplication
    public function setUp()
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...
25
    {
26
        $map = array(
27
            array('multilanguage', true),
28
            array('defaultlocale', 'nl'),
29
            array('requiredlocales', 'nl|fr|en'),
30
        );
31
32
        $this->object = new DomainConfiguration($this->getContainer($map));
33
    }
34
35
    public function testGetSet()
36
    {
37
        $data = $this->object->getLocalesExtraData();
38
        $this->assertCount(0, $data);
39
        $data = $this->object->getFullHostConfig();
40
        $this->assertCount(0, $data);
41
        $this->assertNull($this->object->getFullHost());
42
        $this->assertNull($this->object->getFullHostById(123));
43
        $this->assertNull($this->object->getHostSwitched());
44
        $this->assertNull($this->object->getHostBaseUrl());
45
    }
46
47 View Code Duplication
    private function getContainer($map)
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...
48
    {
49
        $this->container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
50
51
        $this->container
52
            ->method('getParameter')
53
            ->will($this->returnValueMap($map));
54
        $this->container
55
            ->expects($this->any())
56
            ->method('get')
57
            ->with($this->equalTo('request_stack'))
58
            ->willReturn($this->getRequestStack());
59
60
        return $this->container;
61
    }
62
63 View Code Duplication
    private function getRequestStack()
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...
64
    {
65
        $requestStack = $this->createMock('Symfony\Component\HttpFoundation\RequestStack');
66
        $requestStack->expects($this->any())->method('getMasterRequest')->willReturn($this->getRequest());
67
68
        return $requestStack;
69
    }
70
71
    private function getRequest()
72
    {
73
        $request = Request::create('http://domain.tld/');
74
75
        return $request;
76
    }
77
}
78