function UrlTest::testDrupalHttpBuildQuery

Tests drupal_http_build_query().

File

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

Class

UrlTest
Tests for URL generation functions.

Namespace

Drupal\system\Tests\Common

Code

function testDrupalHttpBuildQuery() {
  $this
    ->assertEqual(drupal_http_build_query(array(
    'a' => ' &#//+%20@۞',
  )), 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.');
  $this
    ->assertEqual(drupal_http_build_query(array(
    ' &#//+%20@۞' => 'a',
  )), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.');
  $this
    ->assertEqual(drupal_http_build_query(array(
    'a' => '1',
    'b' => '2',
    'c' => '3',
  )), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.');
  $this
    ->assertEqual(drupal_http_build_query(array(
    'a' => array(
      'b' => '2',
      'c' => '3',
    ),
    'd' => 'foo',
  )), 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.');
}