@@ 17-26 (lines=10) @@ | ||
14 | * @todo There are a ton more permutations of a JSONPath regex |
|
15 | * See the walk() method in JSONStore |
|
16 | */ |
|
17 | public function testIsValidExpression() |
|
18 | { |
|
19 | $field = JSONText::create('MyJSON'); |
|
20 | ||
21 | $this->assertTrue($field->isValidExpression('$..')); |
|
22 | $this->assertTrue($field->isValidExpression('$.[2]')); |
|
23 | $this->assertTrue($field->isValidExpression('$.cars.american[*]')); |
|
24 | $this->assertFalse($field->isValidExpression('$')); |
|
25 | $this->assertFalse($field->isValidExpression('$[2]')); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * @return void |
|
@@ 55-65 (lines=11) @@ | ||
52 | * |
|
53 | * @return void |
|
54 | */ |
|
55 | public function testIsValidDBValue() |
|
56 | { |
|
57 | $field = JSONText::create('MyJSON'); |
|
58 | ||
59 | $this->assertFalse($field->isValidDBValue('true')); |
|
60 | $this->assertFalse($field->isValidDBValue('false')); |
|
61 | $this->assertFalse($field->isValidDBValue('null')); |
|
62 | $this->assertTrue($field->isValidDBValue('')); |
|
63 | $this->assertTrue($field->isValidJson('["one","two"]')); |
|
64 | $this->assertTrue($field->isValidJson('{"cars":{"american":["buick","oldsmobile"]}}')); |
|
65 | } |
|
66 | } |
|
67 |