@@ -36,7 +36,35 @@ public function testFactory(string $id, callable $validator): void
36
36
],
37
37
'config.storage.sync ' => [
38
38
'alias ' => 'config.storage.staging ' ,
39
- ]
39
+ ],
40
+ 'abstract_service ' => [
41
+ 'abstract ' => true ,
42
+ 'class ' => 'Drupal\service_map\MyService ' ,
43
+ ],
44
+ 'concrete_service ' => [
45
+ 'parent ' => 'abstract_service ' ,
46
+ ],
47
+ 'concrete_service_with_a_parent_which_has_a_parent ' => [
48
+ 'parent ' => 'concrete_service ' ,
49
+ ],
50
+ 'abstract_service_private ' => [
51
+ 'abstract ' => true ,
52
+ 'class ' => 'Drupal\service_map\MyService ' ,
53
+ 'public ' => false ,
54
+ ],
55
+ 'concrete_service_overriding_definition_of_its_parent ' => [
56
+ 'parent ' => 'abstract_service_private ' ,
57
+ 'class ' => 'Drupal\service_map\Override ' ,
58
+ 'public ' => true ,
59
+ ],
60
+ 'service_with_unknown_parent ' => [
61
+ 'parent ' => 'unknown_parent ' ,
62
+ ],
63
+ 'service_with_unknown_parent_overriding_definition_of_its_parent ' => [
64
+ 'parent ' => 'unknown_parent ' ,
65
+ 'class ' => 'Drupal\service_map\Override ' ,
66
+ 'public ' => false ,
67
+ ],
40
68
]);
41
69
$ validator ($ service ->getService ($ id ));
42
70
}
@@ -71,6 +99,58 @@ function (DrupalServiceDefinition $service): void {
71
99
self ::assertEquals ('config.storage.staging ' , $ service ->getAlias ());
72
100
}
73
101
];
102
+ yield [
103
+ 'concrete_service ' ,
104
+ function (DrupalServiceDefinition $ service ): void {
105
+ self ::assertEquals ('concrete_service ' , $ service ->getId ());
106
+ self ::assertEquals ('Drupal\service_map\MyService ' , $ service ->getClass ());
107
+ self ::assertTrue ($ service ->isPublic ());
108
+ self ::assertNull ($ service ->getAlias ());
109
+ }
110
+ ];
111
+ yield [
112
+ 'concrete_service_with_a_parent_which_has_a_parent ' ,
113
+ function (DrupalServiceDefinition $ service ): void {
114
+ self ::assertEquals ('concrete_service_with_a_parent_which_has_a_parent ' , $ service ->getId ());
115
+ self ::assertEquals ('Drupal\service_map\MyService ' , $ service ->getClass ());
116
+ self ::assertTrue ($ service ->isPublic ());
117
+ self ::assertNull ($ service ->getAlias ());
118
+ }
119
+ ];
120
+ yield [
121
+ 'abstract_service_private ' ,
122
+ function (DrupalServiceDefinition $ service ): void {
123
+ self ::assertEquals ('abstract_service_private ' , $ service ->getId ());
124
+ self ::assertEquals ('Drupal\service_map\MyService ' , $ service ->getClass ());
125
+ self ::assertFalse ($ service ->isPublic ());
126
+ self ::assertNull ($ service ->getAlias ());
127
+ }
128
+ ];
129
+ yield [
130
+ 'concrete_service_overriding_definition_of_its_parent ' ,
131
+ function (DrupalServiceDefinition $ service ): void {
132
+ self ::assertEquals ('concrete_service_overriding_definition_of_its_parent ' , $ service ->getId ());
133
+ self ::assertEquals ('Drupal\service_map\Override ' , $ service ->getClass ());
134
+ self ::assertTrue ($ service ->isPublic ());
135
+ self ::assertNull ($ service ->getAlias ());
136
+ }
137
+ ];
138
+ yield [
139
+ 'service_with_unknown_parent ' ,
140
+ function (?DrupalServiceDefinition $ service ): void {
141
+ self ::assertNull ($ service );
142
+ }
143
+ ];
144
+
145
+ yield [
146
+ 'service_with_unknown_parent_overriding_definition_of_its_parent ' ,
147
+ function (DrupalServiceDefinition $ service ): void {
148
+ self ::assertEquals ('service_with_unknown_parent_overriding_definition_of_its_parent ' , $ service ->getId ());
149
+ self ::assertEquals ('Drupal\service_map\Override ' , $ service ->getClass ());
150
+ self ::assertFalse ($ service ->isPublic ());
151
+ self ::assertNull ($ service ->getAlias ());
152
+ }
153
+ ];
74
154
}
75
155
76
156
}
0 commit comments