GeolocationTest::testProvidesDefaultValidators()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 16
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright Andreas Heigl<[email protected]>
4
 * 
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
6
 * of this software and associated documentation files (the "Software"), to deal
7
 * in the Software without restriction, including without limitation the rights
8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 * 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 *
23
 * @author    Andreas Heigl<[email protected]>
24
 * @copyright ©2013-2013 Andreas Heigl
25
 * @license   http://www.opesource.org/licenses/mit-license.php MIT-License
26
 * @version   0.0
27
 * @since     29.07.13
28
 * @link      https://github.com/heiglandreas/OrgHeiglGeolocation
29
 */
30
31
namespace Org_Heigl\GeolocationTest\Form\Element;
32
33
use Org_Heigl\Geolocation\Form\Element\Geolocation;
34
use Org_Heigl\Geolocation\Validator\IsGeolocation;
35
use PHPUnit\Framework\TestCase;
36
use Zend\Filter\StringTrim;
37
38
class GeolocationTest extends TestCase
39
{
40 View Code Duplication
    public function testProvidesDefaultValidators()
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...
41
    {
42
        $element = new Geolocation('foo');
43
44
        $inputSpec = $element->getInputSpecification();
45
46
        $this->assertArrayHasKey('validators', $inputSpec);
47
        $this->assertInternalType('array', $inputSpec['validators']);
48
49
        $expectedClasses = array(IsGeolocation::class);
50
51
        foreach ($inputSpec['validators'] as $validator) {
52
            $class = get_class($validator);
53
            $this->assertTrue(in_array($class, $expectedClasses), $class);
54
        }
55
    }
56
57 View Code Duplication
    public function testProvidesDefaultFilters()
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...
58
    {
59
        $element = new Geolocation('foo');
60
61
        $inputSpec = $element->getInputSpecification();
62
63
        $this->assertArrayHasKey('filters', $inputSpec);
64
        $this->assertInternalType('array', $inputSpec['filters']);
65
66
        $expectedClasses = array(
67
            StringTrim::class,
68
            \Org_Heigl\Geolocation\Filter\Geolocation::class,
69
        );
70
71
        foreach ($inputSpec['filters'] as $filter) {
72
            $class = get_class($filter);
73
            $this->assertTrue(in_array($class, $expectedClasses), $class);
74
        }
75
    }
76
77
    public function testSetName()
78
    {
79
        $element = new Geolocation('foo');
80
81
        $inputSpec = $element->getInputSpecification();
82
83
        $this->assertArrayHasKey('name', $inputSpec);
84
        $this->assertInternalType('string', $inputSpec['name']);
85
        $this->assertEquals('foo', $inputSpec['name']);
86
    }
87
}
88