UnsavedPreviewTest.php in Drupal 10
File
core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
class UnsavedPreviewTest extends UITestBase {
public static $testViews = [
'content',
];
protected $defaultTheme = 'stark';
protected $adminUser;
protected static $modules = [
'node',
'views_ui',
];
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp(FALSE, $modules);
$this->adminUser = $this
->drupalCreateUser([
'administer views',
]);
$this
->drupalLogin($this->adminUser);
}
public function testUnsavedPageDisplayPreview() {
$this
->drupalCreateContentType([
'type' => 'page',
]);
for ($i = 0; $i < 5; $i++) {
$this
->drupalCreateNode();
}
$this
->drupalGet('admin/structure/views/view/content');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([], 'Add Page');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('admin/structure/views/nojs/display/content/page_2/path');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([
'path' => 'foobarbaz',
], 'Apply');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([], 'Update preview');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('This display has no path');
$this
->drupalGet('admin/structure/views/view/content/edit/page_2');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([], 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([], 'Update preview');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->linkByHrefExists('foobarbaz');
}
}