public function testCanChangeUrlEncodingDecodingToRfc3986() { $q = new tubepress_url_impl_puzzle_PuzzleBasedQuery(puzzle_Query::fromString('foo=bar%20baz', tubepress_url_impl_puzzle_PuzzleBasedQuery::RFC3986_ENCODING)); $this->assertEquals('bar baz', $q->get('foo')); $this->assertEquals('foo=bar%20baz', (string) $q); }
/** * {@inheritdoc} */ public function setQuery($query) { $this->_assertNotFrozen(); if ($query === null) { $this->_query = null; return $this; } if ($query instanceof tubepress_api_url_QueryInterface) { $this->_query = $query; return $this; } if (is_string($query)) { $puzzleQuery = puzzle_Query::fromString($query); } else { $puzzleQuery = new puzzle_Query($query); } $this->_query = new tubepress_url_impl_puzzle_PuzzleBasedQuery($puzzleQuery); return $this; }
public function testCanChangeUrlEncodingDecodingToRfc3986() { $q = puzzle_Query::fromString('foo=bar%20baz', puzzle_Query::RFC3986); $this->assertEquals('bar baz', $q['foo']); $this->assertEquals('foo=bar%20baz', (string) $q); }
public function testConvertsPlusSymbolsToSpacesByDefault() { $query = puzzle_Query::fromString('var=foo+bar', true); $this->assertEquals('foo bar', $query->get('var')); }
/** * Set the query part of the URL * * @param puzzle_Query|string|array $query Query string value to set. Can * be a string that will be parsed into a puzzle_Query object, an array * of key value pairs, or a puzzle_Query object. * * @return puzzle_Url * @throws InvalidArgumentException */ public function setQuery($query) { if ($query instanceof puzzle_Query) { $this->query = $query; } elseif (is_string($query)) { $this->query = puzzle_Query::fromString($query); } elseif (is_array($query)) { $this->query = new puzzle_Query($query); } else { throw new InvalidArgumentException('Query must be a ' . 'QueryInterface, array, or string'); } return $this; }