getEntityManager()->getRepository(ExportTemplate::class); $template = new ExportTemplate(); $template->setRenderer('csv'); $template->setTitle('csv'); $template->setColumns(['activity.name', 'project.number', 'project.name', 'customer.name', 'user.account_number', 'duration', 'date', 'rate', 'currency']); $template->setLanguage('en'); $template->setLanguage('en'); $repository->saveExportTemplate($template); return $template; } public function testDeleteIsSecure(): void { $this->assertUrlIsSecured('/api/export/1', Request::METHOD_DELETE); } public function testDeleteActionWithUnknownTemplate(): void { $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $this->assertNotFoundForDelete($client, '/api/export/' . PHP_INT_MAX); } public function testDeleteEntityIsSecure(): void { $client = $this->createClient(); $template = $this->importExportTemplate(); $this->assertRequestIsSecured($client, '/api/export/' . $template->getId(), Request::METHOD_DELETE); } public function testDeleteActionWithoutAuthorization(): void { $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $template = $this->importExportTemplate(); $this->request($client, '/api/export/' . $template->getId(), Request::METHOD_DELETE); $response = $client->getResponse(); $this->assertApiResponseAccessDenied($response); } public function testDeleteAction(): void { $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $template = $this->importExportTemplate(); $this->request($client, '/api/export/' . $template->getId(), Request::METHOD_DELETE); self::assertTrue($client->getResponse()->isSuccessful()); self::assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode()); self::assertEmpty($client->getResponse()->getContent()); } }