Skip to content

Commit f3e8e36

Browse files
committed
Merge branch '2.2'
* 2.2: (70 commits) change wrapped exception message to be more usefull updated VERSION for 2.0.23 update CONTRIBUTORS for 2.0.23 updated CHANGELOG for 2.0.23 [Form] fixed failing test [DomCrawler] added support for query string with slash Fixed invalid file path for hiddeninput.exe on Windows. fix xsd definition for strict-requirements [WebProfilerBundle] Fixed the toolbar styles to apply them in IE8 [ClassLoader] fixed heredocs handling fixed handling of heredocs Add a public modifier to an interface method removing xdebug extension [HttpRequest] fixes Request::getLanguages() bug [HttpCache] added a test (cached content should be kept after purging) [DoctrineBridge] Fixed non-utf-8 recognition [Security] fixed HttpUtils class tests replaced new occurences of 'Request::create()' with '::create()' changed sub-requests creation to '::create()' fixed merge issue ... Conflicts: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig src/Symfony/Component/DomCrawler/Link.php src/Symfony/Component/Translation/Translator.php
2 parents 33cc43f + 847f610 commit f3e8e36

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

ContainerAwareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface ContainerAwareInterface
2323
/**
2424
* Sets the Container.
2525
*
26-
* @param ContainerInterface $container A ContainerInterface instance
26+
* @param ContainerInterface|null $container A ContainerInterface instance or null
2727
*
2828
* @api
2929
*/

ContainerBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,15 @@ public function getScopeChildren()
347347
*/
348348
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
349349
{
350+
$id = strtolower($id);
351+
350352
if ($this->isFrozen()) {
351353
// setting a synthetic service on a frozen container is alright
352354
if (!isset($this->definitions[$id]) || !$this->definitions[$id]->isSynthetic()) {
353-
throw new BadMethodCallException('Setting service on a frozen container is not allowed');
355+
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
354356
}
355357
}
356358

357-
$id = strtolower($id);
358-
359359
unset($this->definitions[$id], $this->aliases[$id]);
360360

361361
parent::set($id, $service, $scope);

Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ protected function parseFile($file)
210210
try {
211211
$dom = XmlUtils::loadFile($file, array($this, 'validateSchema'));
212212
} catch (\InvalidArgumentException $e) {
213-
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
213+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
214214
}
215215

216216
$this->validateExtensions($dom, $file);

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testLoad()
5050
$loader->load('foo.xml');
5151
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
5252
} catch (\Exception $e) {
53-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
53+
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
5454
$this->assertStringStartsWith('The file "foo.xml" does not exist (in:', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist');
5555
}
5656
}
@@ -66,7 +66,11 @@ public function testParseFile()
6666
$m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini');
6767
$this->fail('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
6868
} catch (\Exception $e) {
69-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
69+
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
70+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'parameters.ini'), $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
71+
72+
$e = $e->getPrevious();
73+
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
7074
$this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
7175
}
7276

@@ -76,7 +80,11 @@ public function testParseFile()
7680
$m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml');
7781
$this->fail('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD');
7882
} catch (\Exception $e) {
79-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD');
83+
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD');
84+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'nonvalid.xml'), $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
85+
86+
$e = $e->getPrevious();
87+
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD');
8088
$this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD');
8189
}
8290

@@ -262,8 +270,12 @@ public function testExtensions()
262270
$loader->load('extensions/services3.xml');
263271
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
264272
} catch (\Exception $e) {
265-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
266-
$this->assertRegexp('/The attribute \'bar\' is not allowed/', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
273+
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
274+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
275+
276+
$e = $e->getPrevious();
277+
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
278+
$this->assertContains('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
267279
}
268280

269281
// non-registered extension
@@ -295,8 +307,12 @@ public function testExtensionInPhar()
295307
$loader->load('extensions/services7.xml');
296308
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
297309
} catch (\Exception $e) {
298-
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
299-
$this->assertRegexp('/The attribute \'bar\' is not allowed/', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
310+
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
311+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
312+
313+
$e = $e->getPrevious();
314+
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
315+
$this->assertContains('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
300316
}
301317
}
302318

@@ -333,15 +349,23 @@ public function testNoNamingConflictsForAnonymousServices()
333349
$this->assertEquals('BarClass2', $inner2->getClass(), '->load() uses the same configuration as for the anonymous ones');
334350
}
335351

336-
/**
337-
* @expectedException \InvalidArgumentException
338-
* @expectedExceptionMessage Document types are not allowed.
339-
*/
340352
public function testDocTypeIsNotAllowed()
341353
{
342354
$container = new ContainerBuilder();
343355

344-
$loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
345-
$loader1->load('withdoctype.xml');
356+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
357+
358+
// document types are not allowed.
359+
try {
360+
$loader->load('withdoctype.xml');
361+
$this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type');
362+
} catch (\Exception $e) {
363+
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
364+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
365+
366+
$e = $e->getPrevious();
367+
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
368+
$this->assertSame('Document types are not allowed.', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
369+
}
346370
}
347371
}

0 commit comments

Comments
 (0)