Completed
Push — master ( 366fbf...5f1478 )
by Rafael
02:45
created

Object2ArrayInterfaceTest::testPopulate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 12
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\Object2ArrayBuilder;
13
use Rafrsr\LibArray2Object\Tests\Fixtures\Game;
14
use Rafrsr\LibArray2Object\Tests\Fixtures\Team;
15
16
class Object2ArrayInterfaceTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testPopulate()
19
    {
20
        $game = new Game();
21
        $game->setStadiumName('National');
22
        $game->setDate(new \DateTime('2016-01-01'));
23
        $game->setHomeClub(new Team('Team 1'));
24
        $game->setVisitor(new Team('Team 2'));
25
26
        $objectToArray = Object2ArrayBuilder::create()->build();
27
28
        $array = $objectToArray->createArray($game);
29
        static::assertEquals($game->getStadiumName(), $array['stadium']);
30
        static::assertEquals('2016-01-01', $array['date']);
31
        static::assertEquals('Team 1', $array['homeClub']['name']);
32
        static::assertEquals('Team 2', $array['visitor']['name']);
33
    }
34
}
35