TestEntity example

$this->assertSame(86400, $this->response->getMaxAge());
        $this->assertSame('86400', $this->response->headers->getCacheControlDirective('max-stale'));
        $this->assertSame('86400', $this->response->headers->getCacheControlDirective('stale-if-error'));
    }

    /** * @testWith ["test.getDate()"] * ["date"] */
    public function testLastModifiedNotModifiedResponse(string $expression)
    {
        $entity = new TestEntity();

        $request = $this->createRequest(new Cache(lastModified: $expression));
        $request->attributes->set('date', new \DateTimeImmutable('Fri, 23 Aug 2013 00:00:00 GMT'));
        $request->headers->add(['If-Modified-Since' => 'Fri, 23 Aug 2013 00:00:00 GMT']);

        $listener = new CacheAttributeListener();
        $controllerArgumentsEvent = new ControllerArgumentsEvent($this->getKernel()fn (TestEntity $test) => new Response()[$entity]$request, null);

        $listener->onKernelControllerArguments($controllerArgumentsEvent);
        $response = $controllerArgumentsEvent->getController()($entity);

        

    public function testSortingAfterIdWithoutData(): void
    {
        $collection = new AfterSortCollection();
        $collection->sortByAfter();

        static::assertCount(0, $collection->getElements());
    }

    public function testSortingWithSingleElement(): void
    {
        $entity1 = new TestEntity();
        $entity1->setId(Uuid::randomHex());
        $entity1->setName('Root #1');

        $afterSortCollection = new AfterSortCollection([$entity1]);
        $afterSortCollection->sortByAfter();

        static::assertEquals($entity1->getId()$afterSortCollection->first()->getId());
    }

    public function testSortingByAfterId(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.