function GotoTest::testDrupalGetDestination

Tests drupal_get_destination().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php, line 85
Definition of Drupal\system\Tests\Common\GotoTest.

Class

GotoTest
Tests drupal_goto() and hook_drupal_goto_alter().

Namespace

Drupal\system\Tests\Common

Code

function testDrupalGetDestination() {
  $query = $this
    ->randomName(10);

  // Verify that a 'destination' query string is used as destination.
  $this
    ->drupalGet('common-test/destination', array(
    'query' => array(
      'destination' => $query,
    ),
  ));
  $this
    ->assertText('The destination: ' . $query, 'The given query string destination is determined as destination.');

  // Verify that the current path is used as destination.
  $this
    ->drupalGet('common-test/destination', array(
    'query' => array(
      $query => NULL,
    ),
  ));
  $url = 'common-test/destination?' . $query;
  $this
    ->assertText('The destination: ' . $url, 'The current path is determined as destination.');
}