normalize() public method

public normalize ( $object, $format = null, array $context = [] )
$context array
コード例 #1
0
 public function testNormalizePaginator()
 {
     $paginatorProphecy = $this->prophesize(PaginatorInterface::class);
     $paginatorProphecy->getCurrentPage()->willReturn(3)->shouldBeCalled();
     $paginatorProphecy->getLastPage()->willReturn(20)->shouldBeCalled();
     $decoratedNormalizerProphecy = $this->prophesize(NormalizerInterface::class);
     $decoratedNormalizerProphecy->normalize(Argument::type(PaginatorInterface::class), null, Argument::type('array'))->willReturn(['hydra:totalItems' => 40, 'foo' => 'bar'])->shouldBeCalled();
     $normalizer = new PartialCollectionViewNormalizer($decoratedNormalizerProphecy->reveal(), '_page');
     $this->assertEquals(['hydra:totalItems' => 40, 'foo' => 'bar', 'hydra:view' => ['@id' => '/?_page=3', '@type' => 'hydra:PartialCollectionView', 'hydra:first' => '/?_page=1', 'hydra:last' => '/?_page=20', 'hydra:previous' => '/?_page=2', 'hydra:next' => '/?_page=4']], $normalizer->normalize($paginatorProphecy->reveal()));
 }