function UpdateContribTest::testNonStandardVersionStrings

Same name in other branches
  1. 9 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testNonStandardVersionStrings()
  2. 8.9.x core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testNonStandardVersionStrings()
  3. 11.x core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testNonStandardVersionStrings()

Tests messages for invalid, empty and missing version strings.

File

core/modules/update/tests/src/Functional/UpdateContribTest.php, line 798

Class

UpdateContribTest
Tests how the Update Manager handles contributed modules and themes.

Namespace

Drupal\Tests\update\Functional

Code

public function testNonStandardVersionStrings() : void {
    $version_infos = [
        'invalid' => [
            'version' => 'llama',
            'expected' => 'Invalid version: llama',
        ],
        'empty' => [
            'version' => '',
            'expected' => 'Empty version',
        ],
        'null' => [
            'expected' => 'Invalid version: Unknown',
        ],
    ];
    foreach ($version_infos as $version_info) {
        $installed_extensions = [
            'aaa_update_test' => [
                'project' => 'aaa_update_test',
                'hidden' => FALSE,
            ],
        ];
        if (isset($version_info['version'])) {
            $installed_extensions['aaa_update_test']['version'] = $version_info['version'];
        }
        $this->mockInstalledExtensionsInfo($installed_extensions);
        $this->refreshUpdateStatus([
            'drupal' => '8.0.0',
            $this->updateProject => '1_0-supported',
        ]);
        $this->standardTests();
        $this->assertSession()
            ->elementTextContains('css', $this->updateTableLocator, $version_info['expected']);
    }
}

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