public function testNormalizePaginator() { $paginatorProphecy = $this->prophesize(PaginatorInterface::class); $paginatorProphecy->getCurrentPage()->willReturn(3); $paginatorProphecy->getLastPage()->willReturn(7); $paginatorProphecy->getItemsPerPage()->willReturn(12); $paginatorProphecy->getTotalItems()->willReturn(1312); $paginatorProphecy->rewind()->shouldBeCalled(); $paginatorProphecy->valid()->willReturn(true, false)->shouldBeCalled(); $paginatorProphecy->current()->willReturn('foo')->shouldBeCalled(); $paginatorProphecy->next()->willReturn()->shouldBeCalled(); $paginator = $paginatorProphecy->reveal(); $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class); $resourceClassResolverProphecy->getResourceClass($paginator, null, true)->willReturn('Foo')->shouldBeCalled(); $itemNormalizer = $this->prophesize(NormalizerInterface::class); $itemNormalizer->normalize('foo', null, ['api_sub_level' => true, 'resource_class' => 'Foo'])->willReturn(['_links' => ['self' => '/me'], 'name' => 'Kévin']); $normalizer = new CollectionNormalizer($resourceClassResolverProphecy->reveal(), 'page'); $normalizer->setNormalizer($itemNormalizer->reveal()); $expected = ['_links' => ['self' => '/?page=3', 'first' => '/?page=1', 'last' => '/?page=7', 'prev' => '/?page=2', 'next' => '/?page=4', 'item' => ['/me']], '_embedded' => ['item' => [['_links' => ['self' => '/me'], 'name' => 'Kévin']]], 'totalItems' => 1312, 'itemsPerPage' => 12]; $this->assertEquals($expected, $normalizer->normalize($paginator)); }