// 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(LoaderLoadException::
class,
$e, '->load() throws a LoaderLoadException if the imported yaml file does not exist'
);
$this->
assertMatchesRegularExpression(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(FileLocatorFileNotFoundException::
class,
$e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'
);
$this->
assertMatchesRegularExpression(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(LoaderLoadException::
class,
$e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'
);
$this->
assertMatchesRegularExpression(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'
);