File tree 3 files changed +27
-1
lines changed
src/Symfony/Component/DependencyInjection
Loader/schema/dic/services 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 97
97
</xsd : complexType >
98
98
99
99
<xsd : complexType name =" tag" >
100
- <xsd : attribute name =" name" type =" xsd:string" />
100
+ <xsd : attribute name =" name" type =" xsd:string" use = " required " />
101
101
<xsd : anyAttribute namespace =" ##any" processContents =" lax" />
102
102
</xsd : complexType >
103
103
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <container xmlns =" http://symfony.com/schema/dic/services"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
5
+
6
+ <services >
7
+ <service id =" foo" class =" BarClass" >
8
+ <tag foo =" bar" />
9
+ </service >
10
+ </services >
11
+ </container >
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \DependencyInjection \ContainerInterface ;
15
15
use Symfony \Component \DependencyInjection \ContainerBuilder ;
16
+ use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
16
17
use Symfony \Component \DependencyInjection \Reference ;
17
18
use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
18
19
use Symfony \Component \DependencyInjection \Loader \YamlFileLoader ;
@@ -207,6 +208,20 @@ public function testParsesTags()
207
208
}
208
209
}
209
210
211
+ public function testParseTagsWithoutName ()
212
+ {
213
+ try {
214
+ $ container = new ContainerBuilder ();
215
+ $ loader = new XmlFileLoader ($ container , new FileLocator (self ::$ fixturesPath . '/xml ' ));
216
+ $ loader ->load ('invalid_tag.xml ' );
217
+
218
+ $ this ->fail ('The XmlFileLoader is expected to throw an exception when the name attribute is missing or a tag. ' );
219
+ } catch (InvalidArgumentException $ e ) {
220
+ $ this ->assertInstanceOf ('\InvalidArgumentException ' , $ e ->getPrevious ());
221
+ $ this ->assertRegExp ("/The attribute 'name' is required but missing/ " , $ e ->getPrevious ()->getMessage ());
222
+ }
223
+ }
224
+
210
225
public function testConvertDomElementToArray ()
211
226
{
212
227
$ doc = new \DOMDocument ('1.0 ' );
You can’t perform that action at this time.
0 commit comments