GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — develop ( b404ce...b367b9 )
by Baptiste
03:16
created

ReflectionInstanciatorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testThrowWhenClassCannotBeInstanciated() 0 8 1
A testBuild() 0 28 1
A testInterface() 0 5 1
A testGetParameters() 0 13 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Reflection\Instanciator;
5
6
use Innmind\Reflection\{
7
    Instanciator\ReflectionInstanciator,
8
    Instanciator,
9
    Exception\InstanciationFailed,
10
};
11
use Innmind\Immutable\{
12
    Map,
13
    Set,
14
};
15
use function Innmind\Immutable\unwrap;
16
use PHPUnit\Framework\TestCase;
17
18
class ReflectionInstanciatorTest extends TestCase
19
{
20
    public function testInterface()
21
    {
22
        $this->assertInstanceOf(
23
            Instanciator::class,
24
            new ReflectionInstanciator
25
        );
26
    }
27
28
    public function testBuild()
29
    {
30
        $i = new ReflectionInstanciator;
31
32
        $object = $i->build(
33
            Foo::class,
34
            Map::of('string', 'mixed')
35
                ('o', $o = new \stdClass)
36
                ('bar', 'foo')
37
        );
38
39
        $this->assertInstanceOf(Foo::class, $object);
40
        $this->assertSame([$o, 'foo', null], $object->properties);
41
42
        $object = $i->build(
43
            Foo::class,
44
            Map::of('string', 'mixed')
45
                ('o', $o = new \stdClass)
46
                ('bar', 'foo')
47
                ('baz', 42)
48
        );
49
50
        $this->assertInstanceOf(Foo::class, $object);
51
        $this->assertSame([$o, 'foo', 42], $object->properties);
52
53
        $object = $i->build('stdClass', Map::of('string', 'mixed'));
54
55
        $this->assertInstanceOf('stdClass', $object);
56
    }
57
58
    public function testThrowWhenClassCannotBeInstanciated()
59
    {
60
        $i = new ReflectionInstanciator;
61
62
        $this->expectException(InstanciationFailed::class);
63
        $this->expectExceptionMessage('Class "Tests\Innmind\Reflection\Instanciator\Foo" cannot be instanciated');
64
65
        $i->build(Foo::class, Map::of('string', 'mixed'));
66
    }
67
68
    public function testGetParameters()
69
    {
70
        $i = new ReflectionInstanciator;
71
72
        $parameters = $i->parameters(Foo::class);
73
74
        $this->assertInstanceOf(Set::class, $parameters);
75
        $this->assertSame('string', (string) $parameters->type());
76
        $this->assertSame(['o', 'bar', 'baz'], unwrap($parameters));
77
78
        $parameters = $i->parameters('stdClass');
79
80
        $this->assertSame(0, $parameters->count());
81
    }
82
}
83
84
class Foo
85
{
86
    public $properties;
87
88
    public function __construct(\stdClass $o, string $bar, $baz = null)
89
    {
90
        $this->properties = [$o, $bar, $baz];
91
    }
92
}
93