-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathJSONPathTokenTest.php
More file actions
67 lines (55 loc) · 1.88 KB
/
Copy pathJSONPathTokenTest.php
File metadata and controls
67 lines (55 loc) · 1.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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\Filters\IndexesFilter;
use Flow\JSONPath\Filters\IndexFilter;
use Flow\JSONPath\Filters\QueryMatchFilter;
use Flow\JSONPath\Filters\QueryResultFilter;
use Flow\JSONPath\Filters\RecursiveFilter;
use Flow\JSONPath\Filters\SliceFilter;
use Flow\JSONPath\JSONPathToken;
use Flow\JSONPath\TokenType;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(JSONPathToken::class)]
class JSONPathTokenTest extends TestCase
{
public function testBuildFilterReturnsExpectedTypes(): void
{
self::assertInstanceOf(
IndexFilter::class,
new JSONPathToken(TokenType::Index, null)->buildFilter(0)
);
self::assertInstanceOf(
IndexesFilter::class,
new JSONPathToken(TokenType::Indexes, [])->buildFilter(0)
);
self::assertInstanceOf(
QueryMatchFilter::class,
new JSONPathToken(TokenType::QueryMatch, '')->buildFilter(0)
);
self::assertInstanceOf(
QueryResultFilter::class,
new JSONPathToken(TokenType::QueryResult, '')->buildFilter(0)
);
self::assertInstanceOf(
RecursiveFilter::class,
new JSONPathToken(TokenType::Recursive, null)->buildFilter(0)
);
self::assertInstanceOf(
SliceFilter::class,
new JSONPathToken(TokenType::Slice, ['start' => 0, 'end' => 0, 'step' => 1])->buildFilter(0)
);
}
public function testConstructorSetsProperties(): void
{
$token = new JSONPathToken(TokenType::Index, 'value');
self::assertSame(TokenType::Index, $token->type);
self::assertSame('value', $token->value);
}
}