UpgradeRectorUiTest.php in Upgrade Rector 8
File
tests/src/Functional/UpgradeRectorUiTest.php
View source
<?php
namespace Drupal\Tests\upgrade_rector\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class UpgradeRectorUiTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'upgrade_rector',
'upgrade_rector_test_error',
];
public function setUp() : void {
parent::setUp();
$this
->drupalLogin($this
->drupalCreateUser([
'administer software updates',
]));
}
public function testUiBeforeScan() {
$this
->drupalGet(Url::fromRoute('upgrade_rector.run'));
$assert_session = $this
->assertSession();
$assert_session
->buttonExists('Run rector');
$this
->assertCount(2, $this
->getSession()
->getPage()
->findAll('css', 'details'));
}
public function testUiAfterScan() {
$edit = [
'custom[data][project]' => 'upgrade_rector_test_error',
];
$this
->drupalPostForm('admin/reports/upgrade-rector', $edit, 'Run rector');
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$assert_session
->buttonExists('Run rector');
$this
->assertCount(3, $this
->getSession()
->getPage()
->findAll('css', 'details'));
$this
->assertCount(1, $this
->getSession()
->getPage()
->findAll('css', 'details#edit-custom-data-upgrade-rector-test-error'));
$this
->assertSession()
->responseMatches("!upgrade_rector_test_error.module!");
$this
->assertSession()
->responseMatches("!UpgradeRectorTestErrorForm.php!");
$this
->assertSession()
->responseMatches("!DrupalRector\\\\Rector\\\\Deprecation\\\\DrupalSetMessageRector!");
}
}