1+ <?php
2+
3+ namespace TypeSignature \Test ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use TypeSignature \TypeSignature ;
7+
8+ final class TypeSignatureTest extends TestCase
9+ {
10+ public function testArguments (): void
11+ {
12+ $ this ->assertSame ('string, integer ' , TypeSignature::arguments ('string ' , 'integer ' ));
13+ }
14+
15+ public function testBoolean (): void
16+ {
17+ $ this ->assertSame ('bool ' , TypeSignature::boolean ());
18+ }
19+
20+ public function testInteger (): void
21+ {
22+ $ this ->assertSame ('integer ' , TypeSignature::integer ());
23+ }
24+
25+ public function testFloat (): void
26+ {
27+ $ this ->assertSame ('float|double ' , TypeSignature::float ());
28+ }
29+
30+ public function testDouble (): void
31+ {
32+ $ this ->assertSame ('float|double ' , TypeSignature::double ());
33+ }
34+
35+ public function testString (): void
36+ {
37+ $ this ->assertSame ('string ' , TypeSignature::string ());
38+ }
39+
40+ public function testArray (): void
41+ {
42+ $ this ->assertSame ('string[] ' , TypeSignature::array ('string ' ));
43+ $ this ->assertSame ('string[] ' , TypeSignature::array (TypeSignature::array ('string ' )));
44+ }
45+
46+ public function testObject (): void
47+ {
48+ $ this ->assertSame ('object ' , TypeSignature::object ());
49+ }
50+
51+ public function testCallable (): void
52+ {
53+ $ this ->assertSame ('callable ' , TypeSignature::callable ());
54+ }
55+
56+ public function testMixed (): void
57+ {
58+ $ this ->assertSame ('mixed ' , TypeSignature::mixed ());
59+ }
60+
61+ public function testNumber (): void
62+ {
63+ $ this ->assertSame ('integer|float|double ' , TypeSignature::number ());
64+ }
65+
66+ public function testCallback (): void
67+ {
68+ $ this ->assertSame ('callable ' , TypeSignature::callback ());
69+ }
70+
71+ public function testUnion (): void
72+ {
73+ $ this ->assertSame ('integer|string ' , TypeSignature::union (TypeSignature::integer (), TypeSignature::string ()));
74+ }
75+
76+ public function testIntersection (): void
77+ {
78+ $ this ->assertSame ('ArrayAccess&Countable ' , TypeSignature::intersection (\ArrayAccess::class, \Countable::class));
79+ }
80+
81+ public function testOptional (): void
82+ {
83+ $ this ->assertSame ('?string ' , TypeSignature::optional (TypeSignature::string ()));
84+ $ this ->assertSame ('?string ' , TypeSignature::optional (TypeSignature::optional (TypeSignature::string ())));
85+ }
86+ }
0 commit comments