public function XmlFileLoaderTest::testExtensionInPhar in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\XmlFileLoaderTest::testExtensionInPhar()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ Loader/ XmlFileLoaderTest.php, line 367
Class
Namespace
Symfony\Component\DependencyInjection\Tests\LoaderCode
public function testExtensionInPhar() {
if (extension_loaded('suhosin') && false === strpos(ini_get('suhosin.executor.include.whitelist'), 'phar')) {
$this
->markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.');
}
require_once self::$fixturesPath . '/includes/ProjectWithXsdExtensionInPhar.phar';
// extension with an XSD in PHAR archive
$container = new ContainerBuilder();
$container
->registerExtension(new \ProjectWithXsdExtensionInPhar());
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml'));
$loader
->load('extensions/services6.xml');
// extension with an XSD in PHAR archive (does not validate)
try {
$loader
->load('extensions/services7.xml');
$this
->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
} catch (\Exception $e) {
$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".$#', 'services7.xml'), $e
->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$e = $e
->getPrevious();
$this
->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this
->assertContains('The attribute \'bar\' is not allowed', $e
->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
}
}