|
6 | 6 | use Elastica\Query;
|
7 | 7 | use Elastica\Query\MatchAll;
|
8 | 8 | use Elastica\Request;
|
| 9 | +use Elastica\Response; |
9 | 10 | use Elastica\Type\Mapping;
|
10 | 11 | use Elastica\Test\Base as BaseTest;
|
11 | 12 |
|
@@ -79,6 +80,86 @@ public function testIsOkMultiple()
|
79 | 80 | $this->assertTrue($response->isOk());
|
80 | 81 | }
|
81 | 82 |
|
| 83 | + public function testIsOkBulkWithErrorsField() |
| 84 | + { |
| 85 | + $response = new Response(json_encode(array( |
| 86 | + 'took' => 213, |
| 87 | + 'errors' => false, |
| 88 | + 'items' => array( |
| 89 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), |
| 90 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), |
| 91 | + ) |
| 92 | + ))); |
| 93 | + |
| 94 | + $this->assertTrue($response->isOk()); |
| 95 | + } |
| 96 | + |
| 97 | + public function testIsNotOkBulkWithErrorsField() |
| 98 | + { |
| 99 | + $response = new Response(json_encode(array( |
| 100 | + 'took' => 213, |
| 101 | + 'errors' => true, |
| 102 | + 'items' => array( |
| 103 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), |
| 104 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), |
| 105 | + ) |
| 106 | + ))); |
| 107 | + |
| 108 | + $this->assertTrue($response->isOk()); |
| 109 | + } |
| 110 | + |
| 111 | + public function testIsOkBulkItemsWithOkField() |
| 112 | + { |
| 113 | + $response = new Response(json_encode(array( |
| 114 | + 'took' => 213, |
| 115 | + 'items' => array( |
| 116 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)), |
| 117 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => true)), |
| 118 | + ) |
| 119 | + ))); |
| 120 | + |
| 121 | + $this->assertTrue($response->isOk()); |
| 122 | + } |
| 123 | + |
| 124 | + public function testIsNotOkBulkItemsWithOkField() |
| 125 | + { |
| 126 | + $response = new Response(json_encode(array( |
| 127 | + 'took' => 213, |
| 128 | + 'items' => array( |
| 129 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)), |
| 130 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => false)), |
| 131 | + ) |
| 132 | + ))); |
| 133 | + |
| 134 | + $this->assertTrue($response->isOk()); |
| 135 | + } |
| 136 | + |
| 137 | + public function testIsOkBulkItemsWithStatusField() |
| 138 | + { |
| 139 | + $response = new Response(json_encode(array( |
| 140 | + 'took' => 213, |
| 141 | + 'items' => array( |
| 142 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), |
| 143 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), |
| 144 | + ) |
| 145 | + ))); |
| 146 | + |
| 147 | + $this->assertTrue($response->isOk()); |
| 148 | + } |
| 149 | + |
| 150 | + public function testIsNotOkBulkItemsWithStatusField() |
| 151 | + { |
| 152 | + $response = new Response(json_encode(array( |
| 153 | + 'took' => 213, |
| 154 | + 'items' => array( |
| 155 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), |
| 156 | + array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 301)), |
| 157 | + ) |
| 158 | + ))); |
| 159 | + |
| 160 | + $this->assertTrue($response->isOk()); |
| 161 | + } |
| 162 | + |
82 | 163 | public function testGetDataEmpty()
|
83 | 164 | {
|
84 | 165 | $index = $this->_createIndex();
|
|
0 commit comments