createUser(['ROLE_DOCTOR']); $doctor = new Doctor($owner, 'دکتر'); $this->em->persist($doctor); $this->em->flush(); $section = new ServiceSection('doctor', $doctor->getId(), 'بخش'); $item = new ServiceItem($section, 'خدمت'); $this->em->persist($section); $this->em->persist($item); $this->em->flush(); $itemUuid = $item->getUuid(); $this->authJson('DELETE', '/api/v1/service-item/' . $itemUuid, $owner); $this->assertSame(409, $this->responseCode()); // سرویس باید همچنان وجود داشته باشد. $this->em->clear(); $this->assertNotNull($this->em->getRepository(ServiceItem::class)->findOneBy(['uuid' => $itemUuid])); } public function testDeletingSectionIsRejected(): void { $owner = $this->createUser(['ROLE_DOCTOR']); $doctor = new Doctor($owner, 'دکتر'); $this->em->persist($doctor); $this->em->flush(); $section = new ServiceSection('doctor', $doctor->getId(), 'بخش'); $this->em->persist($section); $this->em->flush(); $sectionUuid = $section->getUuid(); $this->authJson('DELETE', '/api/v1/service-section/' . $sectionUuid, $owner); $this->assertSame(409, $this->responseCode()); $this->em->clear(); $this->assertNotNull($this->em->getRepository(ServiceSection::class)->findOneBy(['uuid' => $sectionUuid])); } }