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. 10 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 813

Class

UpdateContribTest
Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.

Namespace

Drupal\Tests\update\Functional

Code

public function testNonStandardVersionStrings() {
    $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) {
        $system_info = [
            'aaa_update_test' => [
                'project' => 'aaa_update_test',
                'hidden' => FALSE,
            ],
        ];
        if (isset($version_info['version'])) {
            $system_info['aaa_update_test']['version'] = $version_info['version'];
        }
        $this->config('update_test.settings')
            ->set('system_info', $system_info)
            ->save();
        $this->refreshUpdateStatus([
            'drupal' => '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.