diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_file_not_found.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_file_not_found.xml
new file mode 100644
index 0000000000000..f3c6814b714b4
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_file_not_found.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_nonvalid.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_nonvalid.xml
new file mode 100644
index 0000000000000..9d026135cdcd2
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_nonvalid.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_with_errors.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_with_errors.xml
new file mode 100644
index 0000000000000..8644f8bacbb59
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services4_bad_import_with_errors.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_file_not_found.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_file_not_found.yml
new file mode 100644
index 0000000000000..d94e53c5a8e3b
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_file_not_found.yml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: foo_fake.yml, ignore_errors: not_found }
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_nonvalid.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_nonvalid.yml
new file mode 100644
index 0000000000000..3ad1c2b63076d
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_nonvalid.yml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: nonvalid2.yml, ignore_errors: not_found }
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_with_errors.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_with_errors.yml
new file mode 100644
index 0000000000000..42bca4ca0674e
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4_bad_import_with_errors.yml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: foo_fake.yml }
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index b5a0296dad3b0..2c5386572a439 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -183,6 +183,37 @@ public function testLoadImports()
// Bad import throws no exception due to ignore_errors value.
$loader->load('services4_bad_import.xml');
+
+ // Bad import with nonexistent file throws no exception due to ignore_errors: not_found value.
+ $loader->load('services4_bad_import_file_not_found.xml');
+
+ try {
+ $loader->load('services4_bad_import_with_errors.xml');
+ $this->fail('->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
+ $this->assertRegExp(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.xml', 'services4_bad_import_with_errors\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
+
+ $e = $e->getPrevious();
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist');
+ $this->assertRegExp(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.xml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist');
+ }
+
+ try {
+ $loader->load('services4_bad_import_nonvalid.xml');
+ $this->fail('->load() throws an LoaderLoadException if the imported configuration does not validate the XSD');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD');
+ $this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD');
+
+ $e = $e->getPrevious();
+ $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
+ $this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
+
+ $e = $e->getPrevious();
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Util\\Exception\\XmlParsingException', $e, '->load() throws a XmlParsingException if the configuration does not validate the XSD');
+ $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->load() throws a XmlParsingException if the loaded file does not validate the XSD');
+ }
}
public function testLoadAnonymousServices()
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 4e3a2bb38b361..2010e36ababb5 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -135,6 +135,33 @@ public function testLoadImports()
// Bad import throws no exception due to ignore_errors value.
$loader->load('services4_bad_import.yml');
+
+ // Bad import with nonexistent file throws no exception due to ignore_errors: not_found value.
+ $loader->load('services4_bad_import_file_not_found.yml');
+
+ try {
+ $loader->load('services4_bad_import_with_errors.yml');
+ $this->fail('->load() throws a LoaderLoadException if the imported yaml file does not exist');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported yaml file does not exist');
+ $this->assertRegExp(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.yml', 'services4_bad_import_with_errors\.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported yaml file does not exist');
+
+ $e = $e->getPrevious();
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist');
+ $this->assertRegExp(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.yml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist');
+ }
+
+ try {
+ $loader->load('services4_bad_import_nonvalid.yml');
+ $this->fail('->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
+ $this->assertRegExp(sprintf('#^The service file ".+%1$s" is not valid\. It should contain an array\. Check your YAML syntax in .+%1$s \(which is being imported from ".+%2$s"\)\.$#', 'nonvalid2\.yml', 'services4_bad_import_nonvalid.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
+
+ $e = $e->getPrevious();
+ $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid');
+ $this->assertRegExp(sprintf('#^The service file ".+%s" is not valid\. It should contain an array\. Check your YAML syntax\.$#', 'nonvalid2\.yml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid');
+ }
}
public function testLoadServices()
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy