Skip to content

Commit 55e6e75

Browse files
committed
Improve name resolution test to show all potential cases.
1 parent c2cbe30 commit 55e6e75

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

Zend/tests/attributes/004_name_resolution.phpt

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Resolve attribute names
55
function dump_attributes($attributes) {
66
$arr = [];
77
foreach ($attributes as $attribute) {
8-
$arr[$attribute->getName()] = $attribute->getArguments();
8+
$arr[] = ['name' => $attribute->getName(), 'args' => $attribute->getArguments()];
99
}
1010
var_dump($arr);
1111
}
@@ -17,24 +17,62 @@ namespace Doctrine\ORM\Mapping {
1717

1818
namespace Foo {
1919
use Doctrine\ORM\Mapping\Entity;
20+
use Doctrine\ORM\Mapping as ORM;
2021

21-
<<Entity(["foo" => "bar"])>>
22+
<<Entity("imported class")>>
23+
<<ORM\Entity("imported namespace")>>
24+
<<\Doctrine\ORM\Mapping\Entity("absolute from namespace")>>
25+
<<\Entity("import absolute from global")>>
2226
function foo() {
2327
}
2428
}
2529

2630
namespace {
31+
class Entity {}
32+
2733
dump_attributes((new ReflectionFunction('Foo\foo'))->getAttributes());
2834
}
2935
?>
3036
--EXPECTF--
31-
array(1) {
32-
["Doctrine\ORM\Mapping\Entity"]=>
33-
array(1) {
34-
[0]=>
37+
array(4) {
38+
[0]=>
39+
array(2) {
40+
["name"]=>
41+
string(27) "Doctrine\ORM\Mapping\Entity"
42+
["args"]=>
43+
array(1) {
44+
[0]=>
45+
string(14) "imported class"
46+
}
47+
}
48+
[1]=>
49+
array(2) {
50+
["name"]=>
51+
string(27) "Doctrine\ORM\Mapping\Entity"
52+
["args"]=>
53+
array(1) {
54+
[0]=>
55+
string(18) "imported namespace"
56+
}
57+
}
58+
[2]=>
59+
array(2) {
60+
["name"]=>
61+
string(27) "Doctrine\ORM\Mapping\Entity"
62+
["args"]=>
63+
array(1) {
64+
[0]=>
65+
string(23) "absolute from namespace"
66+
}
67+
}
68+
[3]=>
69+
array(2) {
70+
["name"]=>
71+
string(6) "Entity"
72+
["args"]=>
3573
array(1) {
36-
["foo"]=>
37-
string(3) "bar"
74+
[0]=>
75+
string(27) "import absolute from global"
3876
}
3977
}
4078
}

0 commit comments

Comments
 (0)