@@ 106-112 (lines=7) @@ | ||
103 | 'foo' => 'bar' |
|
104 | ]; |
|
105 | ||
106 | $this->specify('The key "meta" is required for item.', function () use ($meta) { |
|
107 | $item = $this->service->item($this->book, $this->transformer) |
|
108 | ->setMeta($meta) |
|
109 | ->toArray(); |
|
110 | verify($item)->hasKey('meta'); |
|
111 | verify($item['meta'])->equals($meta); |
|
112 | }); |
|
113 | ||
114 | $this->specify('The key "meta" is required for collection.', function () use ($meta) { |
|
115 | $collection = $this->service->collection([$this->book], $this->transformer) |
|
@@ 114-120 (lines=7) @@ | ||
111 | verify($item['meta'])->equals($meta); |
|
112 | }); |
|
113 | ||
114 | $this->specify('The key "meta" is required for collection.', function () use ($meta) { |
|
115 | $collection = $this->service->collection([$this->book], $this->transformer) |
|
116 | ->setMeta($meta) |
|
117 | ->toArray(); |
|
118 | verify($collection)->hasKey('meta'); |
|
119 | verify($collection['meta'])->equals($meta); |
|
120 | }); |
|
121 | } |
|
122 | ||
123 | /** |
|
@@ 182-187 (lines=6) @@ | ||
179 | */ |
|
180 | public function testAssertResourceKey() |
|
181 | { |
|
182 | $this->specify('The fractal builder resource key can be set.', function () { |
|
183 | $item = $this->service->item($this->book, $this->transformer); |
|
184 | $item->setResourceKey('book'); |
|
185 | $array = $item->toArray(); |
|
186 | verify($array)->hasKey('data'); |
|
187 | }); |
|
188 | ||
189 | $this->specify('The fractal service can set the builder resource key.', function () { |
|
190 | $item = $this->service->item($this->book, $this->transformer, 'book')->toArray(); |
|
@@ 205-212 (lines=8) @@ | ||
202 | */ |
|
203 | public function testAssertPaginator() |
|
204 | { |
|
205 | $this->specify('The collection can have a paginator', function () { |
|
206 | $books = [$this->book]; |
|
207 | $collection = $this->service->collection($books, $this->transformer) |
|
208 | ->setPaginator(new BookPaginator($books)) |
|
209 | ->toArray(); |
|
210 | verify($collection)->hasKey('meta'); |
|
211 | verify($collection['meta'])->hasKey('pagination'); |
|
212 | }); |
|
213 | ||
214 | $this->specify('The item cannot have a paginator', function () { |
|
215 | $this->service->item($this->book, $this->transformer) |