From ddf411e7a9219d7a90e37dfeb31bc4f1dfb63274 Mon Sep 17 00:00:00 2001 From: cmorenov1402 Date: Wed, 26 Mar 2025 11:50:40 +0100 Subject: [PATCH] Add post with invalid deadline test --- tests/Entity/ProjectApi/CreateTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Entity/ProjectApi/CreateTest.php b/tests/Entity/ProjectApi/CreateTest.php index 2ae3da5..54c04e7 100644 --- a/tests/Entity/ProjectApi/CreateTest.php +++ b/tests/Entity/ProjectApi/CreateTest.php @@ -123,18 +123,20 @@ class CreateTest extends ApiTestCase $this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY); } - public function testPostWithInvalidInput(): void + private function testPostWithInvalidInput(array $invalidData): void { $requestData = [ 'title' => 'New Education Project', 'subtitle' => 'Education for the Future', - 'category' => 'nonexistent-category', // invalid category + 'category' => 'education', 'territory' => ['country' => 'ES'], 'description' => 'Detailed project description', 'deadline' => 'minimum', 'video' => 'https://www.youtube.com/watch?v=bnrVQHEXmOk', ]; + $requestData = array_merge($requestData, $invalidData); + $client = static::createClient(); $client->request('POST', self::POST_URL, [ 'headers' => $this->getHeaders($client), @@ -144,6 +146,14 @@ class CreateTest extends ApiTestCase $this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST); } + public function testPostWithInvalidCategory() : void { + $this->testPostWithInvalidInput(['category' => 'nonexistent-category']); + } + + public function testPostWithInvalidDeadline() : void { + $this->testPostWithInvalidInput(['deadline' => 'extended']); + } + public function testPostUnauthorized() { $client = static::createClient();