UpdatePathLastRemovedTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathLastRemovedTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\UpdatePathTestTrait;
class UpdatePathLastRemovedTest extends BrowserTestBase {
use UpdatePathTestTrait;
protected static $modules = [
'update_test_last_removed',
];
protected $defaultTheme = 'stark';
protected $updateUrl;
protected $updateUser;
protected function setUp() {
parent::setUp();
require_once $this->root . '/core/includes/update.inc';
$this->updateUrl = Url::fromRoute('system.db_update');
$this->updateUser = $this
->drupalCreateUser([
'administer software updates',
]);
}
public function testLastRemovedVersion() {
drupal_set_installed_schema_version('update_test_last_removed', 8000);
$this
->drupalLogin($this->updateUser);
$this
->drupalGet($this->updateUrl);
$assert_session = $this
->assertSession();
$assert_session
->pageTextContains('Requirements problem');
$assert_session
->pageTextContains('Unsupported schema version: Update test with hook_update_last_removed() implementation');
$assert_session
->pageTextContains('The installed version of the Update test with hook_update_last_removed() implementation module is too old to update. Update to an intermediate version first (last removed version: 8002, installed version: 8000).');
$assert_session
->linkNotExists('Continue');
drupal_set_installed_schema_version('update_test_last_removed', 8002);
$this
->runUpdates();
$this
->assertEquals(8003, drupal_get_installed_schema_version('update_test_last_removed'));
}
}