scratch – Rev 126
?pathlinks?
<?php
namespace Aura\Uri;
/**
* Test class for Query.
* Generated by PHPUnit on 2012-07-21 at 15:45:19.
*/
class QueryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Query
*/
protected $query;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
$this->query = new Query;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
parent::tearDown();
}
/**
* @covers Aura\Uri\Query::__toString
*/
public function test__toString()
{
$query_string = 'foo=bar&baz=dib';
$this->query->setFromString($query_string);
$actual = $this->query->__toString();
$this->assertEquals($actual, $query_string);
}
/**
* @covers Aura\Uri\Query::setFromString
*/
public function testSetFromString()
{
$query_string = 'foo=bar&baz=dib';
$this->query->setFromString($query_string);
$actual = $this->query->getArrayCopy();
$expected = [
'foo' => 'bar',
'baz' => 'dib',
];
$this->assertEquals($actual, $expected);
}
public function test_deepArrays()
{
$query_string = 'foo[bar]=baz&zim[gir]=dib';
$this->query->setFromString($query_string);
$expect = 'foo%5Bbar%5D=baz&zim%5Bgir%5D=dib';
$actual = $this->query->__toString();
$this->assertEquals($expect, $actual);
}
}