|
@@ 254-262 (lines=9) @@
|
| 251 |
|
/** |
| 252 |
|
* Tests query() by means of path-matching using the Postgres path match operator: '#>' |
| 253 |
|
*/ |
| 254 |
|
public function testQuery_MatchPath_AsJSON() |
| 255 |
|
{ |
| 256 |
|
// Hashed |
| 257 |
|
$field = JSONText\Fields\JSONText::create('MyJSON'); |
| 258 |
|
$field->setValue($this->getFixture('hash_deep')); |
| 259 |
|
$field->setReturnType('json'); |
| 260 |
|
|
| 261 |
|
$this->assertEquals('{"fast":{"Kawasaki":"KR1S250"},"slow":{"Honda":"FS150"}}', $field->query('#>', '{"bikes":"japanese"}')); |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
/** |
| 265 |
|
* Tests query() by means of path-matching using the Postgres path match operator: '#>' but where duplicate keys exist |
|
@@ 285-293 (lines=9) @@
|
| 282 |
|
* Tests query() by means of path-matching using the Postgres path match operator: '#>' but where duplicate keys exist |
| 283 |
|
* for different parent structures in the source data |
| 284 |
|
*/ |
| 285 |
|
public function testQuery_MatchPathDuplicate_AsJSON() |
| 286 |
|
{ |
| 287 |
|
// Hashed |
| 288 |
|
$field = JSONText\Fields\JSONText::create('MyJSON'); |
| 289 |
|
$field->setValue($this->getFixture('hash_dupes')); |
| 290 |
|
$field->setReturnType('json'); |
| 291 |
|
|
| 292 |
|
$this->assertEquals('[{"Subaru":"Impreza"},{"Kawasaki":"KR1S250"}]', $field->query('#>', '{"japanese":"fast"}')); |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
/** |
| 296 |
|
* Get the contents of a fixture |