RedirectTest.php in Drupal 9
File
core/modules/views_ui/tests/src/Functional/RedirectTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
class RedirectTest extends UITestBase {
public static $testViews = [
'test_view',
'test_redirect_view',
];
protected $defaultTheme = 'stark';
public function testRedirect() {
$view_name = 'test_view';
$random_destination = $this
->randomMachineName();
$edit_path = "admin/structure/views/view/{$view_name}/edit";
$this
->drupalGet($edit_path, [
'query' => [
'destination' => $random_destination,
],
]);
$this
->submitForm([], 'Save');
$this
->assertSession()
->addressEquals($random_destination);
$view_name = 'test_redirect_view';
$new_path = $this
->randomMachineName();
$edit_path = "admin/structure/views/view/{$view_name}/edit";
$path_edit_path = "admin/structure/views/nojs/display/{$view_name}/page_1/path";
$this
->drupalGet($path_edit_path);
$this
->submitForm([
'path' => $new_path,
], 'Apply');
$this
->drupalGet($edit_path, [
'query' => [
'destination' => 'test-redirect-view',
],
]);
$this
->submitForm([], 'Save');
$this
->assertSession()
->addressEquals($new_path);
}
}