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

ParserTester::testParse()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 7
nc 3
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\Parser;
11
12
use Rafrsr\LibArray2Object\Parser\ValueParserInterface;
13
14
/**
15
 * Class ParserTester
16
 */
17
abstract class ParserTester extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @return ValueParserInterface
21
     */
22
    abstract public function buildParser();
23
24
    /**
25
     * @return array
26
     */
27
    abstract public function getParseValueMap();
28
29
    /**
30
     * @return array
31
     */
32
    abstract public function getTypes();
33
34
    public function testParse()
35
    {
36
        $parser = $this->buildParser();
37
38
        foreach ($this->getParseValueMap() as $origin => $expectedParsed) {
39
            foreach ($this->getTypes() as $type) {
40
                $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
41
                $parsed = $parser->parseValue($origin, $type, $property, new \stdClass());
42
                static::assertEquals($expectedParsed, $parsed);
43
            }
44
        }
45
    }
46
}