1 common.test CommonURLUnitTestCase::testBackdropHttpBuildQuery()

Test backdrop_http_build_query().

File

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

Class

CommonURLUnitTestCase
All URL testing that does not require a Backdrop bootstrap.

Code

function testBackdropHttpBuildQuery() {
  $this->assertEqual(backdrop_http_build_query(array('a' => ' &#//+%20@۞')), 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.');
  $this->assertEqual(backdrop_http_build_query(array(' &#//+%20@۞' => 'a')), '%20%26%23//%2B%2520%40%DB%9E=a', 'Key was properly encoded.');
  $this->assertEqual(backdrop_http_build_query(array('a' => '1', 'b' => '2', 'c' => '3')), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.');
  $this->assertEqual(backdrop_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.');
}