PagingListingProcessor example


    public function testPrepare(Request $request, Criteria $expected, string $method = Request::METHOD_GET): void
    {
        $request->setMethod($method);
        $criteria = new Criteria();
        $context = $this->createMock(SalesChannelContext::class);

        $config = new StaticSystemConfigService([
            'core.listing.productsPerPage' => 24,
        ]);

        $processor = new PagingListingProcessor($config);
        $processor->prepare($request$criteria$context);

        static::assertSame($expected->getOffset()$criteria->getOffset());
        static::assertSame($expected->getLimit()$criteria->getLimit());
    }

    public static function prepareProvider(): \Generator
    {
        yield 'Provided GET limit will be accepted' => [
            new Request(['limit' => 10]),
            (new Criteria())->setOffset(0)->setLimit(10),
        ];
Home | Imprint | This part of the site doesn't use cookies.