You are here

public function InfoParserUnitTest::testInfoParserBroken in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserBroken()

Test if correct exception is thrown for a broken info file.

@covers ::parse

@expectedException \Drupal\Core\Extension\InfoParserException @expectedExceptionMessageRegExp #broken\.info\.txt#

File

core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php, line 62
Contains \Drupal\Tests\Core\Extension\InfoParserUnitTest.

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInfoParserBroken() {
  $broken_info = <<<BROKEN_INFO
# info.yml for testing broken YAML parsing exception handling.
name: File
type: module
description: 'Defines a file field type.'
package: Core
version: VERSION
core: 8.x
dependencies::;;
  - field
BROKEN_INFO;
  vfsStream::setup('modules');
  vfsStream::create([
    'fixtures' => [
      'broken.info.txt' => $broken_info,
    ],
  ]);
  $filename = vfsStream::url('modules/fixtures/broken.info.txt');
  $this->infoParser
    ->parse($filename);
}