LocationTest::testSuccessfulCreation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace AlexeyKuperhstokh\LocationBundle\Tests\Location;
4
5
use AlexeyKuperhstokh\LocationBundle\Location\Location;
6
7
class LocationTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testSuccessfulCreation()
10
    {
11
        $options = [
12
            "name" => "Eiffel Tower",
13
            "coordinates" => [
14
                "lat" => 21.12,
15
                "long" => 19.56
16
            ]
17
        ];
18
19
        $loc = new Location($options);
20
        $this->assertEquals('Eiffel Tower', $loc->getName());
21
        $this->assertInstanceOf('\AlexeyKuperhstokh\LocationBundle\Location\Coordinates', $loc->getCoordinates());
22
        $this->assertEquals(21.12, $loc->getCoordinates()->getLat());
23
        $this->assertEquals(19.56, $loc->getCoordinates()->getLong());
24
    }
25
26 View Code Duplication
    public function testMissingNameFields()
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...
27
    {
28
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
29
        $options = [
30
            "coordinates" => [
31
                "lat" => 21.12,
32
                "long" => 19.56
33
            ]
34
        ];
35
        new Location($options);
36
    }
37
38
    public function testMissingCoordinatesField()
39
    {
40
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
41
        $options = [
42
            "name" => "Eiffel Tower",
43
        ];
44
        new Location($options);
45
    }
46
47 View Code Duplication
    public function testMissingLatField()
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->setExpectedException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
50
        $options = [
51
            "name" => "Eiffel Tower",
52
            "coordinates" => [
53
                "lat" => 21.12,
54
            ]
55
        ];
56
        new Location($options);
57
    }
58
59 View Code Duplication
    public function testNameWrongType()
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...
60
    {
61
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
62
        $options = [
63
            "name" => [],
64
            "coordinates" => [
65
                "lat" => 21.12,
66
                "long" => 19.56
67
            ]
68
        ];
69
        new Location($options);
70
    }
71
72
    public function testCoordinatesWrongType()
73
    {
74
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
75
        $options = [
76
            "name" => [],
77
            "coordinates" => true
78
        ];
79
        new Location($options);
80
    }
81
82 View Code Duplication
    public function testLatWrongType()
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...
83
    {
84
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
85
        $options = [
86
            "name" => 'Eiffel Tower',
87
            "coordinates" => [
88
                'lat' => [],
89
                'long' => 19.56,
90
            ]
91
        ];
92
        new Location($options);
93
    }
94
95 View Code Duplication
    public function testLongWrongType()
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...
96
    {
97
        $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
98
        $options = [
99
            "name" => 'Eiffel Tower',
100
            "coordinates" => [
101
                'lat' => 19.56,
102
                'long' => "",
103
            ]
104
        ];
105
        new Location($options);
106
    }
107
}
108