function InfoParserUnitTest::testLifecycleLink
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testLifecycleLink()
- 10 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testLifecycleLink()
Tests an info file's lifecycle_link values.
@covers ::parse
@dataProvider providerLifecycleLink
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 467
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testLifecycleLink($lifecycle, $lifecycle_link = NULL, $exception_message = NULL) : void {
$info = <<<INFO
package: Core
core_version_requirement: '*'
version: VERSION
type: module
name: Module for That
lifecycle: {<span class="php-variable">$lifecycle</span>}
INFO;
if ($lifecycle_link) {
$info .= "\nlifecycle_link: {$lifecycle_link}\n";
}
vfsStream::setup('modules');
// Use a random file name to bypass the static caching in
// \Drupal\Core\Extension\InfoParser.
$random = $this->randomMachineName();
$filename = "lifecycle-{$random}.info.yml";
vfsStream::create([
'fixtures' => [
$filename => $info,
],
]);
$path = vfsStream::url("modules/fixtures/{$filename}");
if ($exception_message) {
$this->expectException(InfoParserException::class);
$this->expectExceptionMessage(sprintf($exception_message, $path));
}
$info_values = $this->infoParser
->parse($path);
$this->assertSame($lifecycle, $info_values[ExtensionLifecycle::LIFECYCLE_IDENTIFIER]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.