You are here

public function InfoParserUnitTest::testInfoParserBroken in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserBroken()
  2. 9 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_version_requirement: '*'
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);
}