ImmutableTest::testMagicSetMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Wambo\Core\Immutable;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Class ImmutableTest
9
 * @package Wambo\Core\Immutable
10
 */
11
class ImmutableTest extends TestCase
12
{
13
    /**
14
     * test Immutable Class can be created via constructor
15
     *
16
     * @test
17
     */
18
    public function testConstructor()
19
    {
20
        // arrange
21
        $obj = new ImmutableTraitImpl();
0 ignored issues
show
Unused Code introduced by
$obj is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
    }
23
24
    /**
25
     * test Immutable Class can´t use __constructor again
26
     *
27
     * @test
28
     * @expectedException \Wambo\Core\Immutable\Exception\ImmutableException
29
     */
30
    public function testConstructor_asFunction()
31
    {
32
        // arrange
33
        $obj = new ImmutableTraitImpl();
34
35
        // act
36
        $obj->__construct();
37
    }
38
39
    /**
40
     * @test
41
     * @expectedException \Wambo\Core\Immutable\Exception\ImmutableException
42
     */
43
    public function testMagicSetMethod()
44
    {
45
        // arrange
46
        $obj = new ImmutableTraitImpl();
47
48
        // act
49
        $obj->__set('test', 'test value');
50
    }
51
}