22
33namespace React \Promise ;
44
5+ use Exception ;
6+ use InvalidArgumentException ;
7+
58class FunctionCheckTypehintTest extends TestCase
69{
710 /** @test */
811 public function shouldAcceptClosureCallbackWithTypehint ()
912 {
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 ()));
1215 }
1316
1417 /** @test */
1518 public function shouldAcceptFunctionStringCallbackWithTypehint ()
1619 {
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 ()));
1922 }
2023
2124 /** @test */
2225 public function shouldAcceptInvokableObjectCallbackWithTypehint ()
2326 {
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 ()));
2629 }
2730
2831 /** @test */
2932 public function shouldAcceptObjectMethodCallbackWithTypehint ()
3033 {
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 ()));
3336 }
3437
3538 /** @test */
3639 public function shouldAcceptStaticClassCallbackWithTypehint ()
3740 {
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 ()));
4043 }
4144
4245 /** @test */
4346 public function shouldAcceptClosureCallbackWithoutTypehint ()
4447 {
45- $ this -> assertTrue (_checkTypehint (function (\ InvalidArgumentException $ e ) {
46- }, new \ InvalidArgumentException ()));
48+ self :: assertTrue (_checkTypehint (function (InvalidArgumentException $ e ) {
49+ }, new InvalidArgumentException ()));
4750 }
4851
4952 /** @test */
5053 public function shouldAcceptFunctionStringCallbackWithoutTypehint ()
5154 {
52- $ this -> assertTrue (_checkTypehint (' React\Promise\testCallbackWithoutTypehint ' , new \ InvalidArgumentException ()));
55+ self :: assertTrue (_checkTypehint (new TestCallbackWithTypehintClass () , new InvalidArgumentException ()));
5356 }
5457
5558 /** @test */
5659 public function shouldAcceptInvokableObjectCallbackWithoutTypehint ()
5760 {
58- $ this -> assertTrue (_checkTypehint (new TestCallbackWithoutTypehintClass (), new \ InvalidArgumentException ()));
61+ self :: assertTrue (_checkTypehint (new TestCallbackWithoutTypehintClass (), new InvalidArgumentException ()));
5962 }
6063
6164 /** @test */
6265 public function shouldAcceptObjectMethodCallbackWithoutTypehint ()
6366 {
64- $ this -> assertTrue (_checkTypehint ([new TestCallbackWithoutTypehintClass (), 'testCallback ' ], new \ InvalidArgumentException ()));
67+ self :: assertTrue (_checkTypehint ([new TestCallbackWithoutTypehintClass (), 'testCallback ' ], new InvalidArgumentException ()));
6568 }
6669
6770 /** @test */
6871 public function shouldAcceptStaticClassCallbackWithoutTypehint ()
6972 {
70- $ this -> assertTrue (_checkTypehint ([' React\Promise\ TestCallbackWithoutTypehintClass' , 'testCallbackStatic ' ], new \ InvalidArgumentException ()));
73+ self :: assertTrue (_checkTypehint ([TestCallbackWithoutTypehintClass::class , 'testCallbackStatic ' ], new InvalidArgumentException ()));
7174 }
7275}
7376
74- function testCallbackWithTypehint (\ InvalidArgumentException $ e )
77+ function testCallbackWithTypehint (InvalidArgumentException $ e )
7578{
7679}
7780
@@ -81,15 +84,15 @@ function testCallbackWithoutTypehint()
8184
8285class TestCallbackWithTypehintClass
8386{
84- public function __invoke (\ InvalidArgumentException $ e )
87+ public function __invoke (InvalidArgumentException $ e )
8588 {
8689 }
8790
88- public function testCallback (\ InvalidArgumentException $ e )
91+ public function testCallback (InvalidArgumentException $ e )
8992 {
9093 }
9194
92- public static function testCallbackStatic (\ InvalidArgumentException $ e )
95+ public static function testCallbackStatic (InvalidArgumentException $ e )
9396 {
9497 }
9598}
0 commit comments