forked from SoftCreatR/JSONPath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONPathDashedIndexTest.php
More file actions
50 lines (43 loc) · 1.11 KB
/
JSONPathDashedIndexTest.php
File metadata and controls
50 lines (43 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* JSONPath implementation for PHP.
*
* @license https://github.com/SoftCreatR/JSONPath/blob/main/LICENSE MIT License
*/
declare(strict_types=1);
namespace Flow\JSONPath\Test;
use Flow\JSONPath\JSONPath;
use Flow\JSONPath\JSONPathException;
use PHPUnit\Framework\TestCase;
class JSONPathDashedIndexTest extends TestCase
{
/**
* @return array[]
*/
public function indexDataProvider(): array
{
return [
[
'$.data[test-test-test]',
['data' => ['test-test-test' => 'foo']],
['foo'],
],
[
'$.data[40f35757-2563-4790-b0b1-caa904be455f]',
['data' => ['40f35757-2563-4790-b0b1-caa904be455f' => 'bar']],
['bar'],
],
];
}
/**
* @dataProvider indexDataProvider
*
* @throws JSONPathException
*/
public function testSlice(string $path, array $data, array $expected): void
{
$results = (new JSONPath($data))
->find($path);
self::assertEquals($expected, $results->getData());
}
}