Completed
Push — master ( fef923...c0df34 )
by Rafael
03:03
created

PropertyMatcherTester::testMatch()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 12
Ratio 66.67 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 18
rs 9.4285
cc 3
eloc 12
nc 4
nop 0
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Tests\Matcher;
11
12
use Rafrsr\LibArray2Object\Matcher\PropertyMatcherInterface;
13
14
/**
15
 * Class PropertyMatcherTester
16
 */
17
abstract class PropertyMatcherTester extends \PHPUnit_Framework_TestCase
18
{
19
20
    public function testMatch()
21
    {
22
        $matcher = $this->buildMatcher();
23
24 View Code Duplication
        foreach ($this->getEquals() as $prop => $given) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
26
            $property->expects(static::any())->method('getName')->willReturn($prop);
27
            $msg = sprintf("property '%s' not match with '%s'", $prop, $given);
28
            static::assertTrue($matcher->match($property, $given), $msg);
29
        }
30
31 View Code Duplication
        foreach ($this->getNotEquals() as $prop => $given) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
32
            $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
33
            $property->expects(static::any())->method('getName')->willReturn($prop);
34
            $msg = sprintf("property '%s' match with '%s'", $prop, $given);
35
            static::assertFalse($matcher->match($property, $given), $msg);
36
        }
37
    }
38
39
    /**
40
     * buildMatcher
41
     *
42
     * @return PropertyMatcherInterface
43
     */
44
    abstract public function buildMatcher();
45
46
    /**
47
     * getEquals
48
     *
49
     * @return array
50
     */
51
    abstract public function getEquals();
52
53
    /**
54
     * getNotEquals
55
     *
56
     * @return array
57
     */
58
    abstract public function getNotEquals();
59
}