public function RequestTest::getQueryStringNormalizationData

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php, line 518

Class

RequestTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function getQueryStringNormalizationData() {
  return array(
    array(
      'foo',
      'foo',
      'works with valueless parameters',
    ),
    array(
      'foo=',
      'foo=',
      'includes a dangling equal sign',
    ),
    array(
      'bar=&foo=bar',
      'bar=&foo=bar',
      '->works with empty parameters',
    ),
    array(
      'foo=bar&bar=',
      'bar=&foo=bar',
      'sorts keys alphabetically',
    ),
    // GET parameters, that are submitted from a HTML form, encode spaces as "+" by default (as defined in enctype application/x-www-form-urlencoded).
    // PHP also converts "+" to spaces when filling the global _GET or when using the function parse_str.
    array(
      'him=John%20Doe&her=Jane+Doe',
      'her=Jane%20Doe&him=John%20Doe',
      'normalizes spaces in both encodings "%20" and "+"',
    ),
    array(
      'foo[]=1&foo[]=2',
      'foo%5B%5D=1&foo%5B%5D=2',
      'allows array notation',
    ),
    array(
      'foo=1&foo=2',
      'foo=1&foo=2',
      'allows repeated parameters',
    ),
    array(
      'pa%3Dram=foo%26bar%3Dbaz&test=test',
      'pa%3Dram=foo%26bar%3Dbaz&test=test',
      'works with encoded delimiters',
    ),
    array(
      '0',
      '0',
      'allows "0"',
    ),
    array(
      'Jane Doe&John%20Doe',
      'Jane%20Doe&John%20Doe',
      'normalizes encoding in keys',
    ),
    array(
      'her=Jane Doe&him=John%20Doe',
      'her=Jane%20Doe&him=John%20Doe',
      'normalizes encoding in values',
    ),
    array(
      'foo=bar&&&test&&',
      'foo=bar&test',
      'removes unneeded delimiters',
    ),
    array(
      'formula=e=m*c^2',
      'formula=e%3Dm%2Ac%5E2',
      'correctly treats only the first "=" as delimiter and the next as value',
    ),
    // Ignore pairs with empty key, even if there was a value, e.g. "=value", as such nameless values cannot be retrieved anyway.
    // PHP also does not include them when building _GET.
    array(
      'foo=bar&=a=b&=x=y',
      'foo=bar',
      'removes params with empty key',
    ),
  );
}