| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | trait CanCreate |
||
| 7 | { |
||
| 8 | public function modelFactory($type, $isRI, $i = 0) |
||
| 9 | { |
||
| 10 | $id = 100 + $i * 10; |
||
| 11 | $attributes = [ |
||
| 12 | 'TST_ID' => $id, |
||
| 13 | 'TST_NAME' => 'model #' . $i, |
||
| 14 | 'TST_NUMBER' => $i * 100 + $i * 5, |
||
| 15 | 'TST_CREATION_DATE' => '2019-01-0' . $i |
||
| 16 | ]; |
||
| 17 | |||
| 18 | $expectedModel = [ |
||
| 19 | 'type' => $type, |
||
| 20 | 'id' => strval($id) |
||
| 21 | ]; |
||
| 22 | if (!$isRI) { |
||
| 23 | $expectedModel['attributes'] = $attributes; |
||
| 24 | } |
||
| 25 | |||
| 26 | $model = new ModelForTest; |
||
| 27 | $model->setRawAttributes($attributes); |
||
| 28 | |||
| 29 | return [$model, $expectedModel]; |
||
| 30 | } |
||
| 31 | |||
| 32 | protected function collectionFactory($count, $type, $isRI) |
||
| 33 | { |
||
| 34 | $expected = []; |
||
| 35 | $collection = []; |
||
| 36 | for ($i = 1; $i <= $count; $i++) { |
||
| 37 | list($model, $expectedModel) = $this->modelFactory($type, $isRI, $i); |
||
| 38 | array_push($expected, $expectedModel); |
||
| 39 | array_push($collection, $model); |
||
| 40 | } |
||
| 41 | |||
| 42 | return [collect($collection), $expected]; |
||
| 43 | } |
||
| 45 |