class RedirectTest in Drupal 10
Same name in this branch
- 10 core/modules/views_ui/tests/src/Functional/RedirectTest.php \Drupal\Tests\views_ui\Functional\RedirectTest
- 10 core/modules/system/tests/src/Functional/Form/RedirectTest.php \Drupal\Tests\system\Functional\Form\RedirectTest
Same name and namespace in other branches
- 8 core/modules/views_ui/tests/src/Functional/RedirectTest.php \Drupal\Tests\views_ui\Functional\RedirectTest
- 9 core/modules/views_ui/tests/src/Functional/RedirectTest.php \Drupal\Tests\views_ui\Functional\RedirectTest
Tests the redirecting after saving a views.
@group views_ui
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\views\Functional\ViewTestBase uses ViewResultAssertionTrait
- class \Drupal\Tests\views_ui\Functional\UITestBase
- class \Drupal\Tests\views_ui\Functional\RedirectTest
- class \Drupal\Tests\views_ui\Functional\UITestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses ViewResultAssertionTrait
Expanded class hierarchy of RedirectTest
File
- core/
modules/ views_ui/ tests/ src/ Functional/ RedirectTest.php, line 10
Namespace
Drupal\Tests\views_ui\FunctionalView source
class RedirectTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_view',
'test_redirect_view',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the redirecting.
*/
public function testRedirect() {
$view_name = 'test_view';
$random_destination = $this
->randomMachineName();
$edit_path = "admin/structure/views/view/{$view_name}/edit";
// Verify that the user gets redirected to the expected page defined in the
// destination.
$this
->drupalGet($edit_path, [
'query' => [
'destination' => $random_destination,
],
]);
$this
->submitForm([], 'Save');
$this
->assertSession()
->addressEquals($random_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
->drupalGet($path_edit_path);
$this
->submitForm([
'path' => $new_path,
], 'Apply');
$this
->drupalGet($edit_path, [
'query' => [
'destination' => 'test-redirect-view',
],
]);
$this
->submitForm([], 'Save');
// Verify that the user gets redirected to the expected page after changing
// the URL of a page display.
$this
->assertSession()
->addressEquals($new_path);
}
}