function InfoParserUnitTest::testInvalidLifecycle

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInvalidLifecycle()
  2. 11.x core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInvalidLifecycle()

Tests an info file with invalid lifecycle values.

@covers ::parse

@dataProvider providerInvalidLifecycle

File

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

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInvalidLifecycle($lifecycle, $exception_message) : void {
    $info = <<<INFO
package: Core
core_version_requirement: '*'
version: VERSION
type: module
name: Module for That
INFO;
    $info .= "\nlifecycle: {$lifecycle}\n";
    vfsStream::setup('modules');
    $filename = "lifecycle-{$lifecycle}.info.txt";
    vfsStream::create([
        'fixtures' => [
            $filename => $info,
        ],
    ]);
    $this->expectException('\\Drupal\\Core\\Extension\\InfoParserException');
    $this->expectExceptionMessage($exception_message);
    $info_values = $this->infoParser
        ->parse(vfsStream::url("modules/fixtures/{$filename}"));
    $this->assertEmpty($info_values);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.