ParserTester::testParse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 0
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