@@ 58-70 (lines=13) @@ | ||
55 | /** |
|
56 | * @covers \League\Fractal\Scope::toArray |
|
57 | */ |
|
58 | public function testToArray() |
|
59 | { |
|
60 | $manager = new Manager(); |
|
61 | ||
62 | $resource = new Item(['foo' => 'bar'], function ($data) { |
|
63 | return $data; |
|
64 | }); |
|
65 | ||
66 | $scope = new Scope($manager, $resource); |
|
67 | ||
68 | ||
69 | $this->assertSame(['data' => ['foo' => 'bar']], $scope->toArray()); |
|
70 | } |
|
71 | ||
72 | public function testToJson() |
|
73 | { |
|
@@ 413-432 (lines=20) @@ | ||
410 | $this->assertSame($expectedOutput, $rootScope->toArray()); |
|
411 | } |
|
412 | ||
413 | public function testDefaultIncludeSuccess() |
|
414 | { |
|
415 | $manager = new Manager(); |
|
416 | $manager->setSerializer(new ArraySerializer()); |
|
417 | ||
418 | // Send this stub junk, it has a specific format anyhow |
|
419 | $resource = new Item([], new DefaultIncludeBookTransformer()); |
|
420 | ||
421 | // Try without metadata |
|
422 | $scope = new Scope($manager, $resource); |
|
423 | ||
424 | $expected = [ |
|
425 | 'a' => 'b', |
|
426 | 'author' => [ |
|
427 | 'c' => 'd', |
|
428 | ], |
|
429 | ]; |
|
430 | ||
431 | $this->assertSame($expected, $scope->toArray()); |
|
432 | } |
|
433 | ||
434 | public function testNullResourceIncludeSuccess() |
|
435 | { |
|
@@ 455-466 (lines=12) @@ | ||
452 | /** |
|
453 | * @covers \League\Fractal\Scope::toArray |
|
454 | */ |
|
455 | public function testNullResourceDataAndJustMeta() |
|
456 | { |
|
457 | $manager = new Manager(); |
|
458 | $manager->setSerializer(new ArraySerializerWithNull); |
|
459 | ||
460 | $resource = new NullResource(); |
|
461 | $resource->setMeta(['foo' => 'bar']); |
|
462 | ||
463 | $scope = new Scope($manager, $resource); |
|
464 | ||
465 | $this->assertSame(['meta' => ['foo' => 'bar']], $scope->toArray()); |
|
466 | } |
|
467 | ||
468 | public function tearDown() |
|
469 | { |