ReflectionWriterTest::testSetValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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