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

Array2ObjectInterfaceTest::testPopulate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 13
nc 1
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;
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
}