Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / src / Tests / RedirectTest.php
1 <?php
2
3 namespace Drupal\views_ui\Tests;
4
5 /**
6  * Tests the redirecting after saving a views.
7  *
8  * @group views_ui
9  */
10 class RedirectTest extends UITestBase {
11
12   /**
13    * Views used by this test.
14    *
15    * @var array
16    */
17   public static $testViews = ['test_view', 'test_redirect_view'];
18
19   /**
20    * Tests the redirecting.
21    */
22   public function testRedirect() {
23     $view_name = 'test_view';
24
25     $random_destination = $this->randomMachineName();
26     $edit_path = "admin/structure/views/view/$view_name/edit";
27
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.');
30
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
33     // the new path.
34     $view_name = 'test_redirect_view';
35     $new_path = $this->randomMachineName();
36
37     $edit_path = "admin/structure/views/view/$view_name/edit";
38     $path_edit_path = "admin/structure/views/nojs/display/$view_name/page_1/path";
39
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.');
43   }
44
45 }