From b7754834804bee69cc56ff074bcf8f789d77ed28 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Fri, 2 May 2025 10:53:37 +0200 Subject: [PATCH] Add expected logs in tests --- .../Entity/tests/units/Activity.php | 8 +++++++ .../Entity/tests/units/Subscription.php | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/GaletteActivities/Entity/tests/units/Activity.php b/tests/GaletteActivities/Entity/tests/units/Activity.php index 726d45f..96c263b 100644 --- a/tests/GaletteActivities/Entity/tests/units/Activity.php +++ b/tests/GaletteActivities/Entity/tests/units/Activity.php @@ -85,6 +85,10 @@ public function testCrud(): void ]; $this->assertFalse($activity->check($data)); $this->assertSame(['Name is mandatory'], $activity->getErrors()); + $this->expectLogEntry( + \Analog::ERROR, + 'Name is mandatory' + ); //required activity name $data = [ @@ -94,6 +98,10 @@ public function testCrud(): void ]; $this->assertFalse($activity->check($data)); $this->assertSame(['Type is too long'], $activity->getErrors()); + $this->expectLogEntry( + \Analog::ERROR, + 'Type is too long' + ); //add new activity $data = [ diff --git a/tests/GaletteActivities/Entity/tests/units/Subscription.php b/tests/GaletteActivities/Entity/tests/units/Subscription.php index d2dc488..4bb0764 100644 --- a/tests/GaletteActivities/Entity/tests/units/Subscription.php +++ b/tests/GaletteActivities/Entity/tests/units/Subscription.php @@ -135,6 +135,10 @@ public function testCrud(): void ], $subscription->getErrors() ); + $this->expectLogEntry( + \Analog::ERROR, + 'Activity is mandatory', + ); $data = [ 'activity' => $activity_id, @@ -148,6 +152,10 @@ public function testCrud(): void ], $subscription->getErrors() ); + $this->expectLogEntry( + \Analog::ERROR, + 'Member is mandatory', + ); $data = [ 'activity' => $activity_id, @@ -161,6 +169,10 @@ public function testCrud(): void ], $subscription->getErrors() ); + $this->expectLogEntry( + \Analog::ERROR, + 'Subscription date is mandatory', + ); $data = [ 'activity' => $activity_id, @@ -175,6 +187,10 @@ public function testCrud(): void ], $subscription->getErrors() ); + $this->expectLogEntry( + \Analog::ERROR, + '- Wrong date format (Y-m-d) for Subscription date!', + ); $data = [ 'activity' => $activity_id, @@ -265,6 +281,12 @@ public function testCrud(): void ], $subscription->getErrors() ); + $this->expectLogEntry( + \Analog::ERROR, + $this->zdb->isPostgres() ? + 'duplicate key value violates unique constraint "galette_activities_subscriptions_id_activity_id_adh_key"' : + "Duplicate entry '3-1' for key" + ); } /**