ImmutabilityTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_immutability_of_unset() 0 7 1
A test_immutability_of_set() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TypedArraysTest\Unit;
6
7
use PHPUnit\Framework\TestCase;
8
use TypedArrays\Exceptions\GuardException;
9
use TypedArraysTest\Unit\Fixtures\ImmutableSimpleObjectArray;
10
use TypedArraysTest\Unit\Fixtures\SimpleObject;
11
12
final class ImmutabilityTest extends TestCase
13
{
14
    public function test_immutability_of_set(): void
15
    {
16
        $test = new ImmutableSimpleObjectArray([new SimpleObject()]);
17
18
        $this->expectExceptionObject(GuardException::immutableCannotMutate());
19
20
        $test[] = new SimpleObject();
21
    }
22
23
    public function test_immutability_of_unset(): void
24
    {
25
        $test = new ImmutableSimpleObjectArray([new SimpleObject()]);
26
27
        $this->expectExceptionObject(GuardException::immutableCannotMutate());
28
29
        unset($test[0]);
30
    }
31
}
32