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

ReflectionWriterTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsWritable() 0 7 1
A testSetValue() 0 10 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\Writer;
11
12
use Rafrsr\LibArray2Object\Tests\Fixtures\Team;
13
use Rafrsr\LibArray2Object\Writer\ReflectionWriter;
14
15
class ReflectionWriterTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testIsWritable()
18
    {
19
        $writer = new ReflectionWriter();
20
        static::assertTrue($writer->isWritable(new Team(), 'name'));
21
        static::assertTrue($writer->isWritable(new Team(), 'id'));
22
        static::assertFalse($writer->isWritable(new Team(), 'lastName'));
23
    }
24
25
    public function testSetValue()
26
    {
27
        $writer = new ReflectionWriter();
28
        $team = new Team();
29
        $writer->setValue($team, 'name', 'New Name');
30
        static::assertEquals('New Name', $team->getName());
31
32
        $writer->setValue($team, 'id', 1);
33
        static::assertEquals(1, $team->getId());
34
    }
35
}
36