| @@ 35-54 (lines=20) @@ | ||
| 32 | * |
|
| 33 | * @return void |
|
| 34 | */ |
|
| 35 | public function search() |
|
| 36 | { |
|
| 37 | \Chadicus\FunctionRegistry::set( |
|
| 38 | __NAMESPACE__, |
|
| 39 | 'time', |
|
| 40 | function () { |
|
| 41 | return 1; |
|
| 42 | } |
|
| 43 | ); |
|
| 44 | ||
| 45 | $adapter = new Assets\FakeAdapter(); |
|
| 46 | $client = new Client('aPrivateKey', 'aPublicKey', $adapter); |
|
| 47 | $client->search('a Resource', ['key' => 'value']); |
|
| 48 | $request = $adapter->getRequest(); |
|
| 49 | $hash = md5('1aPrivateKeyaPublicKey'); |
|
| 50 | $expectedUrl = Client::BASE_URL . "a+Resource?key=value&apikey=aPublicKey&ts=1&hash={$hash}"; |
|
| 51 | ||
| 52 | $this->assertSame('GET', $request->getMethod()); |
|
| 53 | $this->assertSame($expectedUrl, $request->getUrl()); |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * Verify proper exceptions thrown when Client is constructed with bad data. |
|
| @@ 139-158 (lines=20) @@ | ||
| 136 | * |
|
| 137 | * @return void |
|
| 138 | */ |
|
| 139 | public function get() |
|
| 140 | { |
|
| 141 | \Chadicus\FunctionRegistry::set( |
|
| 142 | __NAMESPACE__, |
|
| 143 | 'time', |
|
| 144 | function () { |
|
| 145 | return 1; |
|
| 146 | } |
|
| 147 | ); |
|
| 148 | ||
| 149 | $adapter = new Assets\FakeAdapter(); |
|
| 150 | $client = new Client('aPrivateKey', 'aPublicKey', $adapter); |
|
| 151 | $client->get('a Resource', 1); |
|
| 152 | $request = $adapter->getRequest(); |
|
| 153 | $hash = md5('1aPrivateKeyaPublicKey'); |
|
| 154 | $expectedUrl = Client::BASE_URL . "a+Resource/1?apikey=aPublicKey&ts=1&hash={$hash}"; |
|
| 155 | ||
| 156 | $this->assertSame('GET', $request->getMethod()); |
|
| 157 | $this->assertSame($expectedUrl, $request->getUrl()); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Verify proper exceptions thrown when Client is constructed with bad data. |
|