ParserTester   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
buildParser() 0 1 ?
getParseValueMap() 0 1 ?
getTypes() 0 1 ?
A testParse() 0 12 3
1
<?php
2
3
/*
4
 * This file is part of the rafrsr/lib-array2object package.
5
 *
6
 * (c) Rafael SR <https://github.com/rafrsr>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Rafrsr\LibArray2Object\Tests\Parser;
12
13
use Rafrsr\LibArray2Object\Parser\ValueParserInterface;
14
15
/**
16
 * Class ParserTester.
17
 */
18
abstract class ParserTester extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @return ValueParserInterface
22
     */
23
    abstract public function buildParser();
24
25
    /**
26
     * @return array
27
     */
28
    abstract public function getParseValueMap();
29
30
    /**
31
     * @return array
32
     */
33
    abstract public function getTypes();
34
35
    public function testParse()
36
    {
37
        $parser = $this->buildParser();
38
39
        foreach ($this->getParseValueMap() as $origin => $expectedParsed) {
40
            foreach ($this->getTypes() as $type) {
41
                $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
42
                $parsed = $parser->toObjectValue($origin, $type, $property, new \stdClass());
43
                static::assertEquals($expectedParsed, $parsed);
44
            }
45
        }
46
    }
47
}
48