@@ 492-511 (lines=20) @@ | ||
489 | $this->assertSame($expectedOutput, $rootScope->toArray()); |
|
490 | } |
|
491 | ||
492 | public function testDefaultIncludeSuccess() |
|
493 | { |
|
494 | $manager = new Manager(); |
|
495 | $manager->setSerializer(new ArraySerializer()); |
|
496 | ||
497 | // Send this stub junk, it has a specific format anyhow |
|
498 | $resource = new Item([], new DefaultIncludeBookTransformer()); |
|
499 | ||
500 | // Try without metadata |
|
501 | $scope = new Scope($manager, $resource); |
|
502 | ||
503 | $expected = [ |
|
504 | 'a' => 'b', |
|
505 | 'author' => [ |
|
506 | 'c' => 'd', |
|
507 | ], |
|
508 | ]; |
|
509 | ||
510 | $this->assertSame($expected, $scope->toArray()); |
|
511 | } |
|
512 | ||
513 | public function testPrimitiveResourceIncludeSuccess() |
|
514 | { |
|
@@ 513-527 (lines=15) @@ | ||
510 | $this->assertSame($expected, $scope->toArray()); |
|
511 | } |
|
512 | ||
513 | public function testPrimitiveResourceIncludeSuccess() |
|
514 | { |
|
515 | $manager = new Manager(); |
|
516 | $manager->setSerializer(new ArraySerializer()); |
|
517 | ||
518 | $resource = new Item(['price' => '49'], new PrimitiveIncludeBookTransformer); |
|
519 | ||
520 | $scope = new Scope($manager, $resource); |
|
521 | $expected = [ |
|
522 | 'a' => 'b', |
|
523 | 'price' => 49, |
|
524 | ]; |
|
525 | ||
526 | $this->assertSame($expected, $scope->toArray()); |
|
527 | } |
|
528 | ||
529 | public function testNullResourceIncludeSuccess() |
|
530 | { |
|
@@ 529-545 (lines=17) @@ | ||
526 | $this->assertSame($expected, $scope->toArray()); |
|
527 | } |
|
528 | ||
529 | public function testNullResourceIncludeSuccess() |
|
530 | { |
|
531 | $manager = new Manager(); |
|
532 | $manager->setSerializer(new ArraySerializerWithNull); |
|
533 | ||
534 | // Send this stub junk, it has a specific format anyhow |
|
535 | $resource = new Item([], new NullIncludeBookTransformer); |
|
536 | ||
537 | // Try without metadata |
|
538 | $scope = new Scope($manager, $resource); |
|
539 | $expected = [ |
|
540 | 'a' => 'b', |
|
541 | 'author' => null, |
|
542 | ]; |
|
543 | ||
544 | $this->assertSame($expected, $scope->toArray()); |
|
545 | } |
|
546 | ||
547 | /** |
|
548 | * @covers \League\Fractal\Scope::toArray |
|
@@ 550-561 (lines=12) @@ | ||
547 | /** |
|
548 | * @covers \League\Fractal\Scope::toArray |
|
549 | */ |
|
550 | public function testNullResourceDataAndJustMeta() |
|
551 | { |
|
552 | $manager = new Manager(); |
|
553 | $manager->setSerializer(new ArraySerializerWithNull); |
|
554 | ||
555 | $resource = new NullResource(); |
|
556 | $resource->setMeta(['foo' => 'bar']); |
|
557 | ||
558 | $scope = new Scope($manager, $resource); |
|
559 | ||
560 | $this->assertSame(['meta' => ['foo' => 'bar']], $scope->toArray()); |
|
561 | } |
|
562 | ||
563 | /** |
|
564 | * @covers \League\Fractal\Scope::toArray |