function UpdateContribTest::testCoreCompatibilityMessage

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

Tests that core compatibility messages are displayed.

File

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

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 testCoreCompatibilityMessage() {
    $system_info = [
        '#all' => [
            'version' => '8.0.0',
        ],
        'aaa_update_test' => [
            'project' => 'aaa_update_test',
            'version' => '8.x-1.0',
            'hidden' => FALSE,
        ],
    ];
    $this->config('update_test.settings')
        ->set('system_info', $system_info)
        ->save();
    // Confirm that messages are displayed for recommended and latest updates.
    // @todo In https://www.drupal.org/project/drupal/issues/3112962:
    //   Change the calls to 'refreshUpdateStatus()' to use:
    //   - '1.1' instead of '1.1-core_compatibility'.
    //   - '1.1-alpha1' instead of '1.1-alpha1-core_compatibility'.
    //   Delete the files:
    //   - core/modules/update/tests/modules/update_test/drupal.1.1-alpha1-core_compatibility.xml
    //   - core/modules/update/tests/modules/update_test/drupal.1.1-core_compatibility.xml
    $this->refreshUpdateStatus([
        'drupal' => '1.1-core_compatibility',
        'aaa_update_test' => '8.x-1.2',
    ]);
    $this->assertCoreCompatibilityMessage('8.x-1.2', '8.0.0 to 8.1.1', 'Recommended version:');
    $this->assertCoreCompatibilityMessage('8.x-1.3-beta1', '8.0.0, 8.1.1', 'Latest version:');
    // Change the available core releases and confirm that the messages change.
    $this->refreshUpdateStatus([
        'drupal' => '1.1-alpha1-core_compatibility',
        'aaa_update_test' => '8.x-1.2',
    ]);
    $this->assertCoreCompatibilityMessage('8.x-1.2', '8.0.0 to 8.1.0', 'Recommended version:');
    $this->assertCoreCompatibilityMessage('8.x-1.3-beta1', '8.0.0', 'Latest version:');
    // Confirm that messages are displayed for security and 'Also available'
    // updates.
    $this->refreshUpdateStatus([
        'drupal' => '1.1-core_compatibility',
        'aaa_update_test' => 'core_compatibility.8.x-1.2_8.x-2.2',
    ]);
    $this->assertCoreCompatibilityMessage('8.x-1.2', '8.1.0 to 8.1.1', 'Security update:', FALSE);
    $this->assertCoreCompatibilityMessage('8.x-2.2', '8.1.1', 'Also available:', FALSE);
}

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