Skip to content

Commit fe773c9

Browse files
committed
Add tests for annotations inside classes with newinstance
1 parent 3411cd8 commit fe773c9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/test/php/lang/reflection/unittest/AnonymousClassTest.class.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace lang\reflection\unittest;
22

3-
use lang\Reflection;
3+
use lang\{Reflection, Runnable};
44
use test\{Assert, Test};
55

66
class AnonymousClassTest {
@@ -21,4 +21,25 @@ public function fixture() { }
2121

2222
Assert::equals(Test::class, $type->method('fixture')->annotation(Test::class)->type());
2323
}
24+
25+
#[Test]
26+
public function newinstance_string() {
27+
$type= Reflection::type(newinstance(Runnable::class, [], '{
28+
29+
#[\test\Test]
30+
public function run() { }
31+
}'));
32+
33+
Assert::equals(Test::class, $type->method('run')->annotation(Test::class)->type());
34+
}
35+
36+
#[Test]
37+
public function newinstance_map() {
38+
$type= Reflection::type(newinstance(Runnable::class, [], [
39+
40+
'#[\test\Test] run' => function() { }
41+
]));
42+
43+
Assert::equals(Test::class, $type->method('run')->annotation(Test::class)->type());
44+
}
2445
}

0 commit comments

Comments
 (0)