You are here

public function InfoParserUnitTest::testUnparsableCoreVersionRequirement in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testUnparsableCoreVersionRequirement()
  2. 10 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testUnparsableCoreVersionRequirement()

Tests the exception for an unparsable 'core_version_requirement' value.

@covers ::parse

File

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

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testUnparsableCoreVersionRequirement() {
  $unparsable_core_version_requirement = <<<UNPARSABLE_CORE_VERSION_REQUIREMENT
# info.yml for testing invalid core_version_requirement value.
name: Not this module
description: 'Not the module you are looking for.'
package: Core
type: module
version: VERSION
core_version_requirement: not-this-version
UNPARSABLE_CORE_VERSION_REQUIREMENT;
  vfsStream::setup('modules');
  vfsStream::create([
    'fixtures' => [
      'unparsable_core_version_requirement.info.txt' => $unparsable_core_version_requirement,
    ],
  ]);
  $this
    ->expectException(InfoParserException::class);
  $this
    ->expectExceptionMessage("The 'core_version_requirement' constraint (not-this-version) is not a valid value in vfs://modules/fixtures/unparsable_core_version_requirement.info.txt");
  $this->infoParser
    ->parse(vfsStream::url('modules/fixtures/unparsable_core_version_requirement.info.txt'));
}