entityManager = self::getContainer()->get(EntityManagerInterface::class); $this->repository = $this->entityManager->getRepository(QuestionnaireResponse::class); $this->entityManager->getConnection()->beginTransaction(); $this->teamer = (new Teamer())->setFirstName('Kim')->setLastName('Muster')->setGender('d'); $this->entityManager->persist($this->teamer); } protected function tearDown(): void { $this->entityManager->getConnection()->rollBack(); parent::tearDown(); } public function testOnlySubmittedResponsesToThisQuestionnaireAreListed(): void { $submitted = $this->respond($this->escort(), submit: true); $this->respond($this->escort(), submit: false); $this->respond($this->escort(), submit: true, questionnaire: 'other'); $this->assertSame([$submitted], $this->list(new QuestionnaireResponseFilterDto())); } public function testFilterByTeamer(): void { $other = (new Teamer())->setFirstName('Alex')->setLastName('Beispiel')->setGender('d'); $this->entityManager->persist($other); $this->respond($this->escort(teamer: $other), submit: true); $mine = $this->respond($this->escort(), submit: true); $this->assertSame([$mine], $this->list((new QuestionnaireResponseFilterDto())->setTeamer($this->teamer))); } /** * Matched as a substring, and a % typed into the filter is a literal, not a wildcard. */ public function testFilterByHotel(): void { $ranalt = $this->respond($this->escort(hotel: 'Gasthof Ranalt'), submit: true); $this->respond($this->escort(hotel: 'Schwendi'), submit: true); $this->assertSame([$ranalt], $this->list((new QuestionnaireResponseFilterDto())->setHotel('ranalt'))); $this->assertSame([], $this->list((new QuestionnaireResponseFilterDto())->setHotel('%'))); } public function testFilterByEndOfAssignment(): void { $recent = $this->respond($this->escort(dateTo: '2026-03-14'), submit: true); $this->respond($this->escort(dateTo: '2026-01-10'), submit: true); $filter = (new QuestionnaireResponseFilterDto()) ->setDateFrom(new \DateTimeImmutable('2026-03-01')) ->setDateTo(new \DateTimeImmutable('2026-03-14')) ; $this->assertSame([$recent], $this->list($filter)); } /** * @return list */ private function list(QuestionnaireResponseFilterDto $filter): array { $this->entityManager->flush(); return $this->repository->getListQuery(QuestionnaireCatalog::TEAMER_ESCORT, $filter)->getResult(); } }