Skip to content

Commit 7a05d1a

Browse files
committed
Refactor tests
1 parent d3799ba commit 7a05d1a

File tree

2 files changed

+42
-45
lines changed

2 files changed

+42
-45
lines changed

tests/Type/ConstructorsTest.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,43 @@
44

55
namespace Typhoon\Type;
66

7-
use PHPUnit\Framework\Attributes\CoversNothing;
7+
use PHPUnit\Framework\Attributes\CoversFunction;
8+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
89
use PHPUnit\Framework\TestCase;
910
use Typhoon\Type;
1011

11-
#[CoversNothing]
12+
#[CoversFunction('Typhoon\Type\intT')]
13+
#[CoversFunction('Typhoon\Type\intRangeT')]
14+
#[CoversFunction('Typhoon\Type\bitmaskT')]
15+
#[CoversFunction('Typhoon\Type\intMaskT')]
16+
#[CoversFunction('Typhoon\Type\floatT')]
17+
#[CoversFunction('Typhoon\Type\floatRangeT')]
18+
#[CoversFunction('Typhoon\Type\stringT')]
19+
#[CoversFunction('Typhoon\Type\classT')]
20+
#[CoversFunction('Typhoon\Type\optional')]
21+
#[CoversFunction('Typhoon\Type\listT')]
22+
#[CoversFunction('Typhoon\Type\nonEmptyListT')]
23+
#[CoversFunction('Typhoon\Type\listShapeT')]
24+
#[CoversFunction('Typhoon\Type\unsealedListShapeT')]
25+
#[CoversFunction('Typhoon\Type\arrayT')]
26+
#[CoversFunction('Typhoon\Type\nonEmptyArrayT')]
27+
#[CoversFunction('Typhoon\Type\arrayShapeT')]
28+
#[CoversFunction('Typhoon\Type\unsealedArrayShapeT')]
29+
#[CoversFunction('Typhoon\Type\iterableT')]
30+
#[CoversFunction('Typhoon\Type\namedObjectT')]
31+
#[CoversFunction('Typhoon\Type\objectShapeT')]
32+
#[CoversFunction('Typhoon\Type\callableT')]
33+
#[CoversFunction('Typhoon\Type\closureT')]
34+
#[CoversFunction('Typhoon\Type\param')]
35+
#[CoversFunction('Typhoon\Type\constantT')]
36+
#[CoversFunction('Typhoon\Type\constantMaskT')]
37+
#[CoversFunction('Typhoon\Type\classConstantT')]
38+
#[CoversFunction('Typhoon\Type\classConstantMaskT')]
39+
#[CoversFunction('Typhoon\Type\intersectionT')]
40+
#[CoversFunction('Typhoon\Type\andT')]
41+
#[CoversFunction('Typhoon\Type\unionT')]
42+
#[CoversFunction('Typhoon\Type\orT')]
43+
#[CoversFunction('Typhoon\Type\nullOrT')]
1244
final class ConstructorsTest extends TestCase
1345
{
1446
private const NON_TYPE_CONSTRUCTOR_FUNCTIONS = [
@@ -48,4 +80,10 @@ public function testConstantsAreSuffixedWithT(): void
4880
}
4981
}
5082
}
83+
84+
#[DoesNotPerformAssertions]
85+
public function testConstructorsCoverage(): void
86+
{
87+
iterator_to_array(StringifyTest::provideCases(), preserve_keys: false);
88+
}
5189
}

tests/Type/StringifyTest.php

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,13 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\CoversFunction;
99
use PHPUnit\Framework\Attributes\DataProvider;
10-
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
1110
use PHPUnit\Framework\TestCase;
1211
use Typhoon\Type;
1312
use Typhoon\Type\Visitor\Fallback;
1413
use Typhoon\Type\Visitor\Stringify;
1514
use Typhoon\Type\Visitor\WeakVisitor;
1615

1716
#[CoversClass(Stringify::class)]
18-
#[CoversFunction('Typhoon\Type\intT')]
19-
#[CoversFunction('Typhoon\Type\intRangeT')]
20-
#[CoversFunction('Typhoon\Type\bitmaskT')]
21-
#[CoversFunction('Typhoon\Type\intMaskT')]
22-
#[CoversFunction('Typhoon\Type\floatT')]
23-
#[CoversFunction('Typhoon\Type\floatRangeT')]
24-
#[CoversFunction('Typhoon\Type\stringT')]
25-
#[CoversFunction('Typhoon\Type\classT')]
26-
#[CoversFunction('Typhoon\Type\optional')]
27-
#[CoversFunction('Typhoon\Type\listT')]
28-
#[CoversFunction('Typhoon\Type\nonEmptyListT')]
29-
#[CoversFunction('Typhoon\Type\listShapeT')]
30-
#[CoversFunction('Typhoon\Type\unsealedListShapeT')]
31-
#[CoversFunction('Typhoon\Type\arrayT')]
32-
#[CoversFunction('Typhoon\Type\nonEmptyArrayT')]
33-
#[CoversFunction('Typhoon\Type\arrayShapeT')]
34-
#[CoversFunction('Typhoon\Type\unsealedArrayShapeT')]
35-
#[CoversFunction('Typhoon\Type\iterableT')]
36-
#[CoversFunction('Typhoon\Type\objectT')]
37-
#[CoversFunction('Typhoon\Type\objectShapeT')]
38-
#[CoversFunction('Typhoon\Type\namedObjectT')]
39-
#[CoversFunction('Typhoon\Type\callableT')]
40-
#[CoversFunction('Typhoon\Type\closureT')]
41-
#[CoversFunction('Typhoon\Type\param')]
42-
#[CoversFunction('Typhoon\Type\constantT')]
43-
#[CoversFunction('Typhoon\Type\constantMaskT')]
44-
#[CoversFunction('Typhoon\Type\classConstantT')]
45-
#[CoversFunction('Typhoon\Type\classConstantMaskT')]
46-
#[CoversFunction('Typhoon\Type\aliasT')]
47-
#[CoversFunction('Typhoon\Type\intersectionT')]
48-
#[CoversFunction('Typhoon\Type\andT')]
49-
#[CoversFunction('Typhoon\Type\unionT')]
50-
#[CoversFunction('Typhoon\Type\orT')]
51-
#[CoversFunction('Typhoon\Type\nullOrT')]
5217
#[CoversFunction('Typhoon\Type\stringify')]
5318
final class StringifyTest extends TestCase
5419
{
@@ -189,12 +154,6 @@ public static function provideCases(): iterable
189154
yield [classConstantMaskT(\stdClass::class, 'test_*'), 'stdClass::test_*'];
190155
}
191156

192-
#[DoesNotPerformAssertions]
193-
public function testConstructorsCoverage(): void
194-
{
195-
iterator_to_array(self::provideCases(), preserve_keys: false);
196-
}
197-
198157
public function testItCanBeExtended(): void
199158
{
200159
$myStringify = new /** @extends Fallback<non-empty-string> */ class extends Fallback {
@@ -216,8 +175,8 @@ protected function fallback(Type $type): string
216175
}
217176
};
218177

219-
$string = listShapeT([listShapeT([intT])])->accept($myStringify);
178+
$string = listShapeT([orT(intT, listT(intT))])->accept($myStringify);
220179

221-
self::assertSame('list{list{INT}}', $string);
180+
self::assertSame('list{INT|list<INT>}', $string);
222181
}
223182
}

0 commit comments

Comments
 (0)