You are here

public function XmlFileLoaderTest::testDocTypeIsNotAllowed in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php \Symfony\Component\Routing\Tests\Loader\XmlFileLoaderTest::testDocTypeIsNotAllowed()
  2. 8 vendor/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\XmlFileLoaderTest::testDocTypeIsNotAllowed()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\XmlFileLoaderTest::testDocTypeIsNotAllowed()

File

vendor/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php, line 426

Class

XmlFileLoaderTest

Namespace

Symfony\Component\DependencyInjection\Tests\Loader

Code

public function testDocTypeIsNotAllowed() {
  $container = new ContainerBuilder();
  $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml'));

  // document types are not allowed.
  try {
    $loader
      ->load('withdoctype.xml');
    $this
      ->fail('->load() throws an InvalidArgumentException if the configuration contains a document type');
  } catch (\Exception $e) {
    $this
      ->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
    $this
      ->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'withdoctype.xml'), $e
      ->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
    $e = $e
      ->getPrevious();
    $this
      ->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
    $this
      ->assertSame('Document types are not allowed.', $e
      ->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
  }
}