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 ( 4471cd...dae846 )
by Baptiste
03:11
created

testFlagStructureAsMutableWhenUnderlyingKeysAreMutable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 16
rs 9.9
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Immutable\Fixtures;
5
6
use Innmind\Immutable\Map as Structure;
7
use Innmind\BlackBox\Set;
8
use Fixtures\Innmind\Immutable\Map;
9
use PHPUnit\Framework\TestCase;
10
11
class MapTest extends TestCase
12
{
13
    public function testInterface()
14
    {
15
        $this->assertInstanceOf(
16
            Set::class,
17
            new Map(
18
                'string',
19
                'string',
20
                new Set\Chars,
0 ignored issues
show
Bug introduced by
The type Innmind\BlackBox\Set\Chars was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
                new Set\Chars
22
            )
23
        );
24
    }
25
26
    public function testOf()
27
    {
28
        $this->assertInstanceOf(
29
            Map::class,
30
            Map::of(
31
                'string',
32
                'string',
33
                new Set\Chars,
34
                new Set\Chars
35
            )
36
        );
37
    }
38
39
    public function testGenerates100ValuesByDefault()
40
    {
41
        $maps = new Map(
42
            'string',
43
            'int',
44
            new Set\Chars,
45
            Set\Integers::any()
0 ignored issues
show
Bug introduced by
The type Innmind\BlackBox\Set\Integers was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
        );
47
48
        $this->assertInstanceOf(\Generator::class, $maps->values());
49
        $this->assertCount(100, \iterator_to_array($maps->values()));
50
51
        foreach ($maps->values() as $map) {
52
            $this->assertInstanceOf(Set\Value::class, $map);
0 ignored issues
show
Bug introduced by
The type Innmind\BlackBox\Set\Value was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
53
            $this->assertInstanceOf(Structure::class, $map->unwrap());
54
            $this->assertSame('string', (string) $map->unwrap()->keyType());
55
            $this->assertSame('int', (string) $map->unwrap()->valueType());
56
        }
57
    }
58
59
    public function testGeneratesSequencesOfDifferentSizes()
60
    {
61
        $maps = new Map(
62
            'string',
63
            'string',
64
            new Set\Chars,
65
            new Set\Chars,
66
            Set\Integers::between(0, 50)
67
        );
68
        $sizes = [];
69
70
        foreach ($maps->values() as $map) {
71
            $sizes[] = $map->unwrap()->size();
72
        }
73
74
        $this->assertTrue(\count(\array_unique($sizes)) > 1);
75
    }
76
77
    public function testTake()
78
    {
79
        $maps1 = new Map(
80
            'string',
81
            'string',
82
            new Set\Chars,
83
            new Set\Chars
84
        );
85
        $maps2 = $maps1->take(50);
86
87
        $this->assertNotSame($maps1, $maps2);
88
        $this->assertInstanceOf(Map::class, $maps2);
89
        $this->assertCount(100, \iterator_to_array($maps1->values()));
90
        $this->assertCount(50, \iterator_to_array($maps2->values()));
91
    }
92
93
    public function testFilter()
94
    {
95
        $maps = new Map(
96
            'string',
97
            'string',
98
            new Set\Chars,
99
            new Set\Chars
100
        );
101
102
        $this->expectException(\LogicException::class);
103
        $this->expectExceptionMessage('Map set can\'t be filtered, underlying sets must be filtered beforehand');
104
105
        $maps->filter(static function($map): bool {
106
            return $map->size() % 2 === 0;
107
        });
108
    }
109
110
    public function testFlagStructureAsMutableWhenUnderlyingKeysAreMutable()
111
    {
112
        $maps = new Map(
113
            'object',
114
            'string',
115
            Set\Decorate::mutable(
0 ignored issues
show
Bug introduced by
The type Innmind\BlackBox\Set\Decorate was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
116
                fn() => new \stdClass,
117
                new Set\Chars,
118
            ),
119
            new Set\Chars,
120
        );
121
122
        foreach ($maps->values() as $map) {
123
            $this->assertFalse($map->isImmutable());
124
            $this->assertNotSame($map->unwrap(), $map->unwrap());
125
            $this->assertSame($map->unwrap()->size(), $map->unwrap()->size());
126
        }
127
    }
128
129
    public function testFlagStructureAsMutableWhenUnderlyingValuesAreMutable()
130
    {
131
        $maps = new Map(
132
            'string',
133
            'object',
134
            new Set\Chars,
135
            Set\Decorate::mutable(
136
                fn() => new \stdClass,
137
                new Set\Chars,
138
            ),
139
        );
140
141
        foreach ($maps->values() as $map) {
142
            $this->assertFalse($map->isImmutable());
143
            $this->assertNotSame($map->unwrap(), $map->unwrap());
144
        }
145
    }
146
}
147