1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Tests\Innmind\Immutable\Fixtures; |
5
|
|
|
|
6
|
|
|
use Innmind\Immutable\Set as Structure; |
7
|
|
|
use Innmind\BlackBox\Set as DataSet; |
8
|
|
|
use Fixtures\Innmind\Immutable\Set; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class SetTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public function testInterface() |
14
|
|
|
{ |
15
|
|
|
$this->assertInstanceOf( |
16
|
|
|
DataSet::class, |
17
|
|
|
new Set('string', new DataSet\Chars) |
|
|
|
|
18
|
|
|
); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testOf() |
22
|
|
|
{ |
23
|
|
|
$this->assertInstanceOf( |
24
|
|
|
Set::class, |
25
|
|
|
Set::of('string', new DataSet\Chars) |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGenerates100ValuesByDefault() |
30
|
|
|
{ |
31
|
|
|
$sets = new Set('string', new DataSet\Chars); |
32
|
|
|
|
33
|
|
|
$this->assertInstanceOf(\Generator::class, $sets->values()); |
34
|
|
|
$this->assertCount(100, \iterator_to_array($sets->values())); |
35
|
|
|
|
36
|
|
|
foreach ($sets->values() as $set) { |
37
|
|
|
$this->assertInstanceOf(DataSet\Value::class, $set); |
|
|
|
|
38
|
|
|
$this->assertInstanceOf(Structure::class, $set->unwrap()); |
39
|
|
|
$this->assertSame('string', (string) $set->unwrap()->type()); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testGeneratesSequencesOfDifferentSizes() |
44
|
|
|
{ |
45
|
|
|
$sets = new Set( |
46
|
|
|
'string', |
47
|
|
|
new DataSet\Chars, |
48
|
|
|
DataSet\Integers::between(0, 50) |
|
|
|
|
49
|
|
|
); |
50
|
|
|
$sizes = []; |
51
|
|
|
|
52
|
|
|
foreach ($sets->values() as $set) { |
53
|
|
|
$sizes[] = $set->unwrap()->size(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$this->assertTrue(\count(\array_unique($sizes)) > 1); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testTake() |
60
|
|
|
{ |
61
|
|
|
$sets1 = new Set('string', new DataSet\Chars); |
62
|
|
|
$sets2 = $sets1->take(50); |
63
|
|
|
|
64
|
|
|
$this->assertNotSame($sets1, $sets2); |
65
|
|
|
$this->assertInstanceOf(Set::class, $sets2); |
66
|
|
|
$this->assertCount(100, \iterator_to_array($sets1->values())); |
67
|
|
|
$this->assertCount(50, \iterator_to_array($sets2->values())); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testFilter() |
71
|
|
|
{ |
72
|
|
|
$sets = new Set('string', new DataSet\Chars); |
73
|
|
|
|
74
|
|
|
$this->expectException(\LogicException::class); |
75
|
|
|
$this->expectExceptionMessage('Set set can\'t be filtered, underlying set must be filtered beforehand'); |
76
|
|
|
|
77
|
|
|
$sets->filter(static function($set): bool { |
78
|
|
|
return $set->size() % 2 === 0; |
79
|
|
|
}); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testFlagStructureAsMutableWhenUnderlyingSetValuesAreMutable() |
83
|
|
|
{ |
84
|
|
|
$sets = new Set( |
85
|
|
|
'object', |
86
|
|
|
DataSet\Decorate::mutable( |
|
|
|
|
87
|
|
|
fn() => new \stdClass, |
88
|
|
|
new DataSet\Chars, |
89
|
|
|
), |
90
|
|
|
); |
91
|
|
|
|
92
|
|
|
foreach ($sets->values() as $set) { |
93
|
|
|
$this->assertFalse($set->isImmutable()); |
94
|
|
|
$this->assertNotSame($set->unwrap(), $set->unwrap()); |
95
|
|
|
$this->assertSame($set->unwrap()->size(), $set->unwrap()->size()); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths