You are here

public function FunctionsTest::parseQueryProvider in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/tests/FunctionsTest.php \GuzzleHttp\Tests\Psr7\FunctionsTest::parseQueryProvider()

File

vendor/guzzlehttp/psr7/tests/FunctionsTest.php, line 148

Class

FunctionsTest

Namespace

GuzzleHttp\Tests\Psr7

Code

public function parseQueryProvider() {
  return [
    // Does not need to parse when the string is empty
    [
      '',
      [],
    ],
    // Can parse mult-values items
    [
      'q=a&q=b',
      [
        'q' => [
          'a',
          'b',
        ],
      ],
    ],
    // Can parse multi-valued items that use numeric indices
    [
      'q[0]=a&q[1]=b',
      [
        'q[0]' => 'a',
        'q[1]' => 'b',
      ],
    ],
    // Can parse duplicates and does not include numeric indices
    [
      'q[]=a&q[]=b',
      [
        'q[]' => [
          'a',
          'b',
        ],
      ],
    ],
    // Ensures that the value of "q" is an array even though one value
    [
      'q[]=a',
      [
        'q[]' => 'a',
      ],
    ],
    // Does not modify "." to "_" like PHP's parse_str()
    [
      'q.a=a&q.b=b',
      [
        'q.a' => 'a',
        'q.b' => 'b',
      ],
    ],
    // Can decode %20 to " "
    [
      'q%20a=a%20b',
      [
        'q a' => 'a b',
      ],
    ],
    // Can parse funky strings with no values by assigning each to null
    [
      'q&a',
      [
        'q' => null,
        'a' => null,
      ],
    ],
    // Does not strip trailing equal signs
    [
      'data=abc=',
      [
        'data' => 'abc=',
      ],
    ],
    // Can store duplicates without affecting other values
    [
      'foo=a&foo=b&?µ=c',
      [
        'foo' => [
          'a',
          'b',
        ],
        '?µ' => 'c',
      ],
    ],
    // Sets value to null when no "=" is present
    [
      'foo',
      [
        'foo' => null,
      ],
    ],
    // Preserves "0" keys.
    [
      '0',
      [
        '0' => null,
      ],
    ],
    // Sets the value to an empty string when "=" is present
    [
      '0=',
      [
        '0' => '',
      ],
    ],
    // Preserves falsey keys
    [
      'var=0',
      [
        'var' => '0',
      ],
    ],
    [
      'a[b][c]=1&a[b][c]=2',
      [
        'a[b][c]' => [
          '1',
          '2',
        ],
      ],
    ],
    [
      'a[b]=c&a[d]=e',
      [
        'a[b]' => 'c',
        'a[d]' => 'e',
      ],
    ],
    // Ensure it doesn't leave things behind with repeated values
    // Can parse mult-values items
    [
      'q=a&q=b&q=c',
      [
        'q' => [
          'a',
          'b',
          'c',
        ],
      ],
    ],
  ];
}