public function RedirectTest::testRedirect in Zircon Profile 8
Same name in this branch
- 8 core/modules/views_ui/src/Tests/RedirectTest.php \Drupal\views_ui\Tests\RedirectTest::testRedirect()
- 8 core/modules/system/src/Tests/Form/RedirectTest.php \Drupal\system\Tests\Form\RedirectTest::testRedirect()
Same name and namespace in other branches
- 8.0 core/modules/views_ui/src/Tests/RedirectTest.php \Drupal\views_ui\Tests\RedirectTest::testRedirect()
Tests the redirecting.
File
- core/
modules/ views_ui/ src/ Tests/ RedirectTest.php, line 27 - Contains \Drupal\views_ui\Tests\RedirectTest.
Class
- RedirectTest
- Tests the redirecting after saving a views.
Namespace
Drupal\views_ui\TestsCode
public function testRedirect() {
$view_name = 'test_view';
$random_destination = $this
->randomMachineName();
$edit_path = "admin/structure/views/view/{$view_name}/edit";
$this
->drupalPostForm($edit_path, array(), t('Save'), array(
'query' => array(
'destination' => $random_destination,
),
));
$this
->assertUrl($random_destination, array(), 'Make sure the user got redirected to the expected page defined in the destination.');
// Setup a view with a certain page display path. If you change the path
// but have the old url in the destination the user should be redirected to
// the new path.
$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
->drupalPostForm($path_edit_path, array(
'path' => $new_path,
), t('Apply'));
$this
->drupalPostForm($edit_path, array(), t('Save'), array(
'query' => array(
'destination' => 'test-redirect-view',
),
));
$this
->assertUrl($new_path, array(), 'Make sure the user got redirected to the expected page after changing the url of a page display.');
}