function InfoParserUnitTest::testInfoParserBroken

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserBroken()
  2. 10 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserBroken()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserBroken()

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

@covers ::parse

File

core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php, line 56

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->expectException('\\Drupal\\Core\\Extension\\InfoParserException');
    $this->expectExceptionMessage('broken.info.txt');
    $this->infoParser
        ->parse($filename);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.