MigrateControllerTest.php in Drupal 8
File
core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
View source
<?php
namespace Drupal\Tests\migrate_drupal_ui\Functional;
use Drupal\views\Entity\View;
use Drupal\Tests\BrowserTestBase;
class MigrateControllerTest extends BrowserTestBase {
protected static $modules = [
'dblog',
'migrate_drupal_ui',
'views_ui',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this
->drupalLogin($this->rootUser);
\Drupal::logger('migrate_drupal_ui')
->notice('A test message');
}
public function testUpgradeReport() {
$session = $this
->assertSession();
$this
->assertTrue(View::load('watchdog')
->status(), 'Watchdog view is enabled');
$this
->drupalGet('admin/reports/upgrade');
$session
->optionExists('type[]', 'migrate_drupal_ui')
->isSelected();
$session
->pageTextContainsOnce('A test message');
$this
->drupalGet('admin/structure/views');
$this
->assertTrue($this
->clickViewsOperationsLink('Disable', '/watchdog/'));
$session
->statusCodeEquals(200);
$this
->drupalGet('admin/reports/upgrade');
$session
->optionExists('type[]', 'migrate_drupal_ui')
->isSelected();
$session
->pageTextContainsOnce('A test message');
\Drupal::service('module_installer')
->uninstall([
'views_ui',
'views',
]);
$this
->drupalGet('admin/reports/upgrade');
$session
->optionExists('type[]', 'migrate_drupal_ui')
->isSelected();
$session
->pageTextContainsOnce('A test message');
}
public function clickViewsOperationsLink($label, $href_part) {
$links = $this
->xpath('//a[normalize-space(text())=:label]', [
':label' => (string) $label,
]);
foreach ($links as $link_index => $link) {
$position = strpos($link
->getAttribute('href'), $href_part);
if ($position !== FALSE) {
$index = $link_index;
$this
->clickLink((string) $label, $index);
return TRUE;
}
}
return FALSE;
}
}