public function XmlFileLoaderTest::testExtensionInPhar

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php, line 275

Class

XmlFileLoaderTest

Namespace

Symfony\Component\DependencyInjection\Tests\Loader

Code

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('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
    $this
      ->assertRegexp('/The attribute \'bar\' is not allowed/', $e
      ->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
  }
}