@@ 50-62 (lines=13) @@ | ||
47 | $this->assertEquals([], $field->getValueAsIterable()); |
|
48 | } |
|
49 | ||
50 | public function testFirst_AsArray() |
|
51 | { |
|
52 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
53 | $field->setValue($this->getFixture('array_simple')); |
|
54 | $field->setReturnType('array'); |
|
55 | $this->assertEquals([0 => 'great wall'], $field->first()); |
|
56 | ||
57 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
58 | $field->setValue($this->getFixture('empty')); |
|
59 | $field->setReturnType('array'); |
|
60 | $this->assertInternalType('array', $field->first()); |
|
61 | $this->assertCount(0, $field->first()); |
|
62 | } |
|
63 | ||
64 | public function testFirst_AsJson() |
|
65 | { |
|
@@ 64-76 (lines=13) @@ | ||
61 | $this->assertCount(0, $field->first()); |
|
62 | } |
|
63 | ||
64 | public function testFirst_AsJson() |
|
65 | { |
|
66 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
67 | $field->setValue($this->getFixture('array_simple')); |
|
68 | $field->setReturnType('json'); |
|
69 | $this->assertEquals('["great wall"]', $field->first()); |
|
70 | ||
71 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
72 | $field->setValue($this->getFixture('empty')); |
|
73 | $field->setReturnType('json'); |
|
74 | $this->assertInternalType('string', $field->first()); |
|
75 | $this->assertEquals('[]', $field->first()); |
|
76 | } |
|
77 | ||
78 | public function testLast_AsArray() |
|
79 | { |
|
@@ 78-90 (lines=13) @@ | ||
75 | $this->assertEquals('[]', $field->first()); |
|
76 | } |
|
77 | ||
78 | public function testLast_AsArray() |
|
79 | { |
|
80 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
81 | $field->setValue($this->getFixture('array_simple')); |
|
82 | $field->setReturnType('array'); |
|
83 | $this->assertEquals([6 => 'morris'], $field->last()); |
|
84 | ||
85 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
86 | $field->setValue($this->getFixture('empty')); |
|
87 | $field->setReturnType('array'); |
|
88 | $this->assertInternalType('array', $field->first()); |
|
89 | $this->assertCount(0, $field->first()); |
|
90 | } |
|
91 | ||
92 | public function testLast_AsJson() |
|
93 | { |
|
@@ 92-104 (lines=13) @@ | ||
89 | $this->assertCount(0, $field->first()); |
|
90 | } |
|
91 | ||
92 | public function testLast_AsJson() |
|
93 | { |
|
94 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
95 | $field->setValue($this->getFixture('array_simple')); |
|
96 | $field->setReturnType('json'); |
|
97 | $this->assertEquals('{"6":"morris"}', $field->last()); |
|
98 | ||
99 | $field = JSONText\Fields\JSONText::create('MyJSON'); |
|
100 | $field->setValue($this->getFixture('empty')); |
|
101 | $field->setReturnType('json'); |
|
102 | $this->assertInternalType('string', $field->first()); |
|
103 | $this->assertEquals('[]', $field->first()); |
|
104 | } |
|
105 | ||
106 | public function testNth_AsArray() |
|
107 | { |