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

ParserTester   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

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
 * 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
}