function InfoParserUnitTest::testInvalidLifecycle

Same name and namespace in other branches
  1. 10 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 762

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInvalidLifecycle($lifecycle, $exception_message) {
    $info = <<<INFO
package: Core
core: 8.x
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.