3 namespace Drupal\views_ui\Tests;
6 * Tests the redirecting after saving a views.
10 class RedirectTest extends UITestBase {
13 * Views used by this test.
17 public static $testViews = ['test_view', 'test_redirect_view'];
20 * Tests the redirecting.
22 public function testRedirect() {
23 $view_name = 'test_view';
25 $random_destination = $this->randomMachineName();
26 $edit_path = "admin/structure/views/view/$view_name/edit";
28 $this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => $random_destination]]);
29 $this->assertUrl($random_destination, [], 'Make sure the user got redirected to the expected page defined in the destination.');
31 // Setup a view with a certain page display path. If you change the path
32 // but have the old url in the destination the user should be redirected to
34 $view_name = 'test_redirect_view';
35 $new_path = $this->randomMachineName();
37 $edit_path = "admin/structure/views/view/$view_name/edit";
38 $path_edit_path = "admin/structure/views/nojs/display/$view_name/page_1/path";
40 $this->drupalPostForm($path_edit_path, ['path' => $new_path], t('Apply'));
41 $this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => 'test-redirect-view']]);
42 $this->assertUrl($new_path, [], 'Make sure the user got redirected to the expected page after changing the URL of a page display.');