| @@ 34-46 (lines=13) @@ | ||
| 31 | $this->assertEquals([], $field->getValueAsIterable()); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testFirst_AsArray() |
|
| 35 | { |
|
| 36 | $field = JSONText::create('MyJSON'); |
|
| 37 | $field->setValue($this->fixture['indexed']); |
|
| 38 | $field->setReturnType('array'); |
|
| 39 | $this->assertEquals([0 => 'great wall'], $field->first()); |
|
| 40 | ||
| 41 | $field = JSONText::create('MyJSON'); |
|
| 42 | $field->setValue($this->fixture['empty']); |
|
| 43 | $field->setReturnType('array'); |
|
| 44 | $this->assertInternalType('array', $field->first()); |
|
| 45 | $this->assertCount(0, $field->first()); |
|
| 46 | } |
|
| 47 | ||
| 48 | public function testFirst_AsJson() |
|
| 49 | { |
|
| @@ 48-60 (lines=13) @@ | ||
| 45 | $this->assertCount(0, $field->first()); |
|
| 46 | } |
|
| 47 | ||
| 48 | public function testFirst_AsJson() |
|
| 49 | { |
|
| 50 | $field = JSONText::create('MyJSON'); |
|
| 51 | $field->setValue($this->fixture['indexed']); |
|
| 52 | $field->setReturnType('json'); |
|
| 53 | $this->assertEquals('["great wall"]', $field->first()); |
|
| 54 | ||
| 55 | $field = JSONText::create('MyJSON'); |
|
| 56 | $field->setValue($this->fixture['empty']); |
|
| 57 | $field->setReturnType('json'); |
|
| 58 | $this->assertInternalType('string', $field->first()); |
|
| 59 | $this->assertEquals('[]', $field->first()); |
|
| 60 | } |
|
| 61 | ||
| 62 | public function testLast_AsArray() |
|
| 63 | { |
|
| @@ 62-74 (lines=13) @@ | ||
| 59 | $this->assertEquals('[]', $field->first()); |
|
| 60 | } |
|
| 61 | ||
| 62 | public function testLast_AsArray() |
|
| 63 | { |
|
| 64 | $field = JSONText::create('MyJSON'); |
|
| 65 | $field->setValue($this->fixture['indexed']); |
|
| 66 | $field->setReturnType('array'); |
|
| 67 | $this->assertEquals([6 => 'morris'], $field->last()); |
|
| 68 | ||
| 69 | $field = JSONText::create('MyJSON'); |
|
| 70 | $field->setValue($this->fixture['empty']); |
|
| 71 | $field->setReturnType('array'); |
|
| 72 | $this->assertInternalType('array', $field->first()); |
|
| 73 | $this->assertCount(0, $field->first()); |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testLast_AsJson() |
|
| 77 | { |
|
| @@ 76-88 (lines=13) @@ | ||
| 73 | $this->assertCount(0, $field->first()); |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testLast_AsJson() |
|
| 77 | { |
|
| 78 | $field = JSONText::create('MyJSON'); |
|
| 79 | $field->setValue($this->fixture['indexed']); |
|
| 80 | $field->setReturnType('json'); |
|
| 81 | $this->assertEquals('{"6":"morris"}', $field->last()); |
|
| 82 | ||
| 83 | $field = JSONText::create('MyJSON'); |
|
| 84 | $field->setValue($this->fixture['empty']); |
|
| 85 | $field->setReturnType('json'); |
|
| 86 | $this->assertInternalType('string', $field->first()); |
|
| 87 | $this->assertEquals('[]', $field->first()); |
|
| 88 | } |
|
| 89 | ||
| 90 | public function testNth_AsArray() |
|
| 91 | { |
|