Passed
Pull Request — master (#24)
by Jesús
03:25
created

NullabilityTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 12
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_nullability() 0 4 1
A test_nullability_of_unset() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TypedArraysTest\Unit;
6
7
use PHPUnit\Framework\TestCase;
8
use TypedArrays\Exceptions\InvalidTypeException;
9
use TypedArraysTest\Unit\Fixtures\NonNullableSimpleObjectArray;
10
use TypedArraysTest\Unit\Fixtures\NullableSimpleObjectArray;
11
use TypedArraysTest\Unit\Fixtures\SimpleObject;
12
13
final class NullabilityTest extends TestCase
14
{
15
    public function test_nullability(): void
16
    {
17
        $test = new NullableSimpleObjectArray([new SimpleObject('valid'), null]);
18
        self::assertNull($test[1]);
19
    }
20
21
    public function test_nullability_of_unset(): void
22
    {
23
        $this->expectException(InvalidTypeException::class);
24
        new NonNullableSimpleObjectArray([new SimpleObject('invalid'), null]);
25
    }
26
}
27