UpdateTestBase.php in Taxonomy access fix 8.2
File
tests/src/Functional/Update/UpdateTestBase.php
View source
<?php
namespace Drupal\Tests\taxonomy_access_fix\Functional\Update;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\RequirementsPageTrait;
if (!trait_exists('\\Drupal\\Tests\\RequirementsPageTrait')) {
class_alias('\\Drupal\\Tests\\taxonomy_access_fix\\Traits\\TaxonomyAccessFixFallbackRequirementsPageTrait', '\\Drupal\\Tests\\RequirementsPageTrait');
}
abstract class UpdateTestBase extends BrowserTestBase {
use RequirementsPageTrait;
public static $modules = [
'taxonomy_access_fix',
];
protected $user;
protected $updateUrl;
protected function setUp() {
parent::setUp();
require_once $this->root . '/core/includes/update.inc';
$this->user = $this
->drupalCreateUser([
'administer software updates',
'access site in maintenance mode',
]);
$this->updateUrl = Url::fromRoute('system.db_update');
}
public abstract function testUpdateHook();
protected function runUpdate(int $previous_schema, int $target_schema, string $raw_message) {
drupal_set_installed_schema_version('taxonomy_access_fix', $previous_schema);
$this
->assertIdentical((int) drupal_get_installed_schema_version('taxonomy_access_fix', TRUE), $previous_schema, new FormattableMarkup('Schema of taxonomy_access_fix is @schema', [
'@schema' => $previous_schema,
]));
$this
->drupalLogin($this->user);
$this
->drupalGet($this->updateUrl, [
'external' => TRUE,
]);
$this
->updateRequirementsProblem();
$this
->clickLink(t('Continue'));
$this
->assertRaw('taxonomy_access_fix module');
$this
->assertRaw((string) $target_schema . ' - ');
$this
->assertRaw($raw_message);
$this
->clickLink(t('Apply pending updates'));
$this
->checkForMetaRefresh();
$this
->assertIdentical((int) drupal_get_installed_schema_version('taxonomy_access_fix', TRUE), $target_schema, new FormattableMarkup('Schema of taxonomy_access_fix is @schema', [
'@schema' => $target_schema,
]));
}
}
Classes
Name |
Description |
UpdateTestBase |
Provides an abstract base class to test Taxonomy Access Fix update hooks. |