public function InfoParserUnitTest::testInvalidCore in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInvalidCore()
Tests a invalid 'core' key.
@covers ::parse
@dataProvider providerInvalidCore
File
- core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 244
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testInvalidCore($core, $filename) {
$invalid_core = <<<INVALID_CORE
# info.yml for testing invalid core key.
package: Core
core: {<span class="php-variable">$core</span>}
core_version_requirement: ^8 || ^9
version: VERSION
type: module
name: Llama or Alpaca
description: Tells whether an image is of a Llama or Alpaca
dependencies:
- llama_detector
- alpaca_detector
INVALID_CORE;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
"invalid_core-{$filename}.info.txt" => $invalid_core,
"invalid_core-{$filename}-duplicate.info.txt" => $invalid_core,
],
]);
$exception_message = "'core: {$core}' is not supported. Use 'core_version_requirement' to specify core compatibility. Only 'core: 8.x' is supported to provide backwards compatibility for Drupal 8 when needed in vfs://modules/fixtures/invalid_core-{$filename}";
// Set the expected exception for the 2nd call to parse().
$this
->expectException('\\Drupal\\Core\\Extension\\InfoParserException');
$this
->expectExceptionMessage("{$exception_message}-duplicate.info.txt");
try {
$this->infoParser
->parse(vfsStream::url("modules/fixtures/invalid_core-{$filename}.info.txt"));
} catch (InfoParserException $exception) {
$this
->assertSame("{$exception_message}.info.txt", $exception
->getMessage());
$this->infoParser
->parse(vfsStream::url("modules/fixtures/invalid_core-{$filename}-duplicate.info.txt"));
}
}