2
2
3
3
namespace React \Promise ;
4
4
5
+ use Exception ;
6
+ use InvalidArgumentException ;
7
+
5
8
class FunctionCheckTypehintTest extends TestCase
6
9
{
7
10
/** @test */
8
11
public function shouldAcceptClosureCallbackWithTypehint ()
9
12
{
10
- $ this -> assertTrue (_checkTypehint (function (\ InvalidArgumentException $ e ) {}, new \ InvalidArgumentException ()));
11
- $ this -> assertFalse (_checkTypehint (function (\ InvalidArgumentException $ e ) {}, new \ Exception ()));
13
+ self :: assertTrue (_checkTypehint (function (InvalidArgumentException $ e ) {}, new InvalidArgumentException ()));
14
+ self :: assertFalse (_checkTypehint (function (InvalidArgumentException $ e ) {}, new Exception ()));
12
15
}
13
16
14
17
/** @test */
15
18
public function shouldAcceptFunctionStringCallbackWithTypehint ()
16
19
{
17
- $ this -> assertTrue (_checkTypehint (' React\Promise\testCallbackWithTypehint ' , new \ InvalidArgumentException ()));
18
- $ this -> assertFalse (_checkTypehint (' React\Promise\testCallbackWithTypehint ' , new \ Exception ()));
20
+ self :: assertTrue (_checkTypehint (new TestCallbackWithTypehintClass () , new InvalidArgumentException ()));
21
+ self :: assertFalse (_checkTypehint (new TestCallbackWithTypehintClass () , new Exception ()));
19
22
}
20
23
21
24
/** @test */
22
25
public function shouldAcceptInvokableObjectCallbackWithTypehint ()
23
26
{
24
- $ this -> assertTrue (_checkTypehint (new TestCallbackWithTypehintClass (), new \ InvalidArgumentException ()));
25
- $ this -> assertFalse (_checkTypehint (new TestCallbackWithTypehintClass (), new \ Exception ()));
27
+ self :: assertTrue (_checkTypehint (new TestCallbackWithTypehintClass (), new InvalidArgumentException ()));
28
+ self :: assertFalse (_checkTypehint (new TestCallbackWithTypehintClass (), new Exception ()));
26
29
}
27
30
28
31
/** @test */
29
32
public function shouldAcceptObjectMethodCallbackWithTypehint ()
30
33
{
31
- $ this -> assertTrue (_checkTypehint ([new TestCallbackWithTypehintClass (), 'testCallback ' ], new \ InvalidArgumentException ()));
32
- $ this -> assertFalse (_checkTypehint ([new TestCallbackWithTypehintClass (), 'testCallback ' ], new \ Exception ()));
34
+ self :: assertTrue (_checkTypehint ([new TestCallbackWithTypehintClass (), 'testCallback ' ], new InvalidArgumentException ()));
35
+ self :: assertFalse (_checkTypehint ([new TestCallbackWithTypehintClass (), 'testCallback ' ], new Exception ()));
33
36
}
34
37
35
38
/** @test */
36
39
public function shouldAcceptStaticClassCallbackWithTypehint ()
37
40
{
38
- $ this -> assertTrue (_checkTypehint ([' React\Promise\ TestCallbackWithTypehintClass' , 'testCallbackStatic ' ], new \ InvalidArgumentException ()));
39
- $ this -> assertFalse (_checkTypehint ([' React\Promise\ TestCallbackWithTypehintClass' , 'testCallbackStatic ' ], new \ Exception ()));
41
+ self :: assertTrue (_checkTypehint ([TestCallbackWithTypehintClass::class , 'testCallbackStatic ' ], new InvalidArgumentException ()));
42
+ self :: assertFalse (_checkTypehint ([TestCallbackWithTypehintClass::class , 'testCallbackStatic ' ], new Exception ()));
40
43
}
41
44
42
45
/** @test */
43
46
public function shouldAcceptClosureCallbackWithoutTypehint ()
44
47
{
45
- $ this -> assertTrue (_checkTypehint (function (\ InvalidArgumentException $ e ) {
46
- }, new \ InvalidArgumentException ()));
48
+ self :: assertTrue (_checkTypehint (function (InvalidArgumentException $ e ) {
49
+ }, new InvalidArgumentException ()));
47
50
}
48
51
49
52
/** @test */
50
53
public function shouldAcceptFunctionStringCallbackWithoutTypehint ()
51
54
{
52
- $ this -> assertTrue (_checkTypehint (' React\Promise\testCallbackWithoutTypehint ' , new \ InvalidArgumentException ()));
55
+ self :: assertTrue (_checkTypehint (new TestCallbackWithTypehintClass () , new InvalidArgumentException ()));
53
56
}
54
57
55
58
/** @test */
56
59
public function shouldAcceptInvokableObjectCallbackWithoutTypehint ()
57
60
{
58
- $ this -> assertTrue (_checkTypehint (new TestCallbackWithoutTypehintClass (), new \ InvalidArgumentException ()));
61
+ self :: assertTrue (_checkTypehint (new TestCallbackWithoutTypehintClass (), new InvalidArgumentException ()));
59
62
}
60
63
61
64
/** @test */
62
65
public function shouldAcceptObjectMethodCallbackWithoutTypehint ()
63
66
{
64
- $ this -> assertTrue (_checkTypehint ([new TestCallbackWithoutTypehintClass (), 'testCallback ' ], new \ InvalidArgumentException ()));
67
+ self :: assertTrue (_checkTypehint ([new TestCallbackWithoutTypehintClass (), 'testCallback ' ], new InvalidArgumentException ()));
65
68
}
66
69
67
70
/** @test */
68
71
public function shouldAcceptStaticClassCallbackWithoutTypehint ()
69
72
{
70
- $ this -> assertTrue (_checkTypehint ([' React\Promise\ TestCallbackWithoutTypehintClass' , 'testCallbackStatic ' ], new \ InvalidArgumentException ()));
73
+ self :: assertTrue (_checkTypehint ([TestCallbackWithoutTypehintClass::class , 'testCallbackStatic ' ], new InvalidArgumentException ()));
71
74
}
72
75
}
73
76
74
- function testCallbackWithTypehint (\ InvalidArgumentException $ e )
77
+ function testCallbackWithTypehint (InvalidArgumentException $ e )
75
78
{
76
79
}
77
80
@@ -81,15 +84,15 @@ function testCallbackWithoutTypehint()
81
84
82
85
class TestCallbackWithTypehintClass
83
86
{
84
- public function __invoke (\ InvalidArgumentException $ e )
87
+ public function __invoke (InvalidArgumentException $ e )
85
88
{
86
89
}
87
90
88
- public function testCallback (\ InvalidArgumentException $ e )
91
+ public function testCallback (InvalidArgumentException $ e )
89
92
{
90
93
}
91
94
92
- public static function testCallbackStatic (\ InvalidArgumentException $ e )
95
+ public static function testCallbackStatic (InvalidArgumentException $ e )
93
96
{
94
97
}
95
98
}
0 commit comments