You are here

function CommonURLUnitTest::testDrupalHttpBuildQuery in Drupal 7

Test drupal_http_build_query().

File

modules/simpletest/tests/common.test, line 168
Tests for common.inc functionality.

Class

CommonURLUnitTest
Tests for URL generation functions.

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%5Bb%5D=2&a%5Bc%5D=3&d=foo', 'Nested array was properly encoded.');
}