public function InfoParserUnitTest::testValidLifecycle in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testValidLifecycle()
Tests an info file with valid lifecycle values.
@covers ::parse
@dataProvider providerValidLifecycle
File
- core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 381
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testValidLifecycle($lifecycle, $expected) {
$info = <<<INFO
package: Core
core_version_requirement: '*'
version: VERSION
type: module
name: Module for That
INFO;
if (!empty($lifecycle)) {
$info .= "\nlifecycle: {$lifecycle}\n";
}
if (in_array($lifecycle, [
ExtensionLifecycle::DEPRECATED,
ExtensionLifecycle::OBSOLETE,
], TRUE)) {
$info .= "\nlifecycle_link: http://example.com\n";
}
vfsStream::setup('modules');
$filename = "lifecycle-{$lifecycle}.info.yml";
vfsStream::create([
'fixtures' => [
$filename => $info,
],
]);
$info_values = $this->infoParser
->parse(vfsStream::url("modules/fixtures/{$filename}"));
$this
->assertSame($expected, $info_values[ExtensionLifecycle::LIFECYCLE_IDENTIFIER]);
}