ReflectionWriterTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsWritable() 0 7 1
A testSetValue() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the rafrsr/lib-array2object package.
5
 *
6
 * (c) Rafael SR <https://github.com/rafrsr>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Rafrsr\LibArray2Object\Tests\Writer;
12
13
use Rafrsr\LibArray2Object\Tests\Fixtures\Team;
14
use Rafrsr\LibArray2Object\Writer\ReflectionWriter;
15
16
class ReflectionWriterTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testIsWritable()
19
    {
20
        $writer = new ReflectionWriter();
21
        static::assertTrue($writer->isWritable(new Team(), 'name'));
22
        static::assertTrue($writer->isWritable(new Team(), 'id'));
23
        static::assertFalse($writer->isWritable(new Team(), 'lastName'));
24
    }
25
26
    public function testSetValue()
27
    {
28
        $writer = new ReflectionWriter();
29
        $team = new Team();
30
        $writer->setValue($team, 'name', 'New Name');
31
        static::assertEquals('New Name', $team->getName());
32
33
        $writer->setValue($team, 'id', 1);
34
        static::assertEquals(1, $team->getId());
35
    }
36
}
37