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

ObjectParserTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 16 1
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\Array2ObjectContext;
13
use Rafrsr\LibArray2Object\Matcher\CamelizeMatcher;
14
use Rafrsr\LibArray2Object\Parser\ObjectParser;
15
use Rafrsr\LibArray2Object\Parser\StringParser;
16
use Rafrsr\LibArray2Object\Tests\Fixtures\Team;
17
use Rafrsr\LibArray2Object\Writer\AccessorWriter;
18
19
class ObjectParserTest extends \PHPUnit_Framework_TestCase
20
{
21
    public function testParse()
22
    {
23
        $context = new Array2ObjectContext();
24
        $context->setWriter(new AccessorWriter());
25
        $context->setMatcher(new CamelizeMatcher());
26
        $context->setParsers([new StringParser()]);
27
        $parser = new ObjectParser($context);
28
29
        $object = new Team();
30
        $property = new \ReflectionProperty(get_class($object), 'name');
31
32
        /** @var Team $team */
33
        $team = $parser->parseValue(['name' => 'New Name'], 'Team', $property, $object);
34
        static::assertInstanceOf(Team::class, $team);
35
        static::assertEquals('New Name', $team->getName());
36
    }
37
}
38