scratch – Blame information for rev 126
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
126 | office | 1 | <?php |
2 | namespace Aura\Uri; |
||
3 | |||
4 | /** |
||
5 | * Test class for Query. |
||
6 | * Generated by PHPUnit on 2012-07-21 at 15:45:19. |
||
7 | */ |
||
8 | class QueryTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | /** |
||
11 | * @var Query |
||
12 | */ |
||
13 | protected $query; |
||
14 | |||
15 | /** |
||
16 | * Sets up the fixture, for example, opens a network connection. |
||
17 | * This method is called before a test is executed. |
||
18 | */ |
||
19 | protected function setUp() |
||
20 | { |
||
21 | parent::setUp(); |
||
22 | $this->query = new Query; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Tears down the fixture, for example, closes a network connection. |
||
27 | * This method is called after a test is executed. |
||
28 | */ |
||
29 | protected function tearDown() |
||
30 | { |
||
31 | parent::tearDown(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @covers Aura\Uri\Query::__toString |
||
36 | */ |
||
37 | public function test__toString() |
||
38 | { |
||
39 | $query_string = 'foo=bar&baz=dib'; |
||
40 | $this->query->setFromString($query_string); |
||
41 | $actual = $this->query->__toString(); |
||
42 | $this->assertEquals($actual, $query_string); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @covers Aura\Uri\Query::setFromString |
||
47 | */ |
||
48 | public function testSetFromString() |
||
49 | { |
||
50 | $query_string = 'foo=bar&baz=dib'; |
||
51 | $this->query->setFromString($query_string); |
||
52 | $actual = $this->query->getArrayCopy(); |
||
53 | $expected = [ |
||
54 | 'foo' => 'bar', |
||
55 | 'baz' => 'dib', |
||
56 | ]; |
||
57 | $this->assertEquals($actual, $expected); |
||
58 | } |
||
59 | |||
60 | public function test_deepArrays() |
||
61 | { |
||
62 | $query_string = 'foo[bar]=baz&zim[gir]=dib'; |
||
63 | $this->query->setFromString($query_string); |
||
64 | $expect = 'foo%5Bbar%5D=baz&zim%5Bgir%5D=dib'; |
||
65 | $actual = $this->query->__toString(); |
||
66 | $this->assertEquals($expect, $actual); |
||
67 | } |
||
68 | } |