Completed
Push — master ( a4b03a...366fbf )
by Rafael
02:33
created

Array2ObjectInterfaceTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPopulate() 0 22 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;
11
12
use Rafrsr\LibArray2Object\Array2ObjectBuilder;
13
use Rafrsr\LibArray2Object\Tests\Fixtures\Game;
14
15
/**
16
 * Class Array2ObjectInterfaceTest
17
 */
18
class Array2ObjectInterfaceTest extends \PHPUnit_Framework_TestCase
19
{
20
    public function testPopulate()
21
    {
22
        $gameArray = [
23
            'stadium' => 'National',
24
            'date' => '2016-01-01',
25
            'homeClub' => [
26
                'name' => 'Team 1'
27
            ],
28
            'visitor' => [
29
                'name' => 'Team 2'
30
            ]
31
        ];
32
33
        //register custom parser
34
        $array2Object = Array2ObjectBuilder::create()->build();
35
36
        /** @var Game $game */
37
        $game = $array2Object->createObject(Game::class, $gameArray);
38
        static::assertEquals('National', $game->getStadiumName());
39
        static::assertEquals('Team 1', $game->getHomeClub()->getName());
40
        static::assertEquals('Team 2', $game->getVisitor()->getName());
41
    }
42
}