Skip to content

Commit 1a10dd2

Browse files
committed
Simplified exception tests for Gravity validatation.
In future the testWrongGeometry function in the Tests/GeometryTest.php can also be cleaned up in a similar way.
1 parent 197908e commit 1a10dd2

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Tests/GravityTest.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,11 @@ public function provideValidGravities(): ?\Generator
7676
*/
7777
public function testWrongGravities($gravity): void
7878
{
79+
$this->expectException(\InvalidArgumentException::class);
80+
$this->expectExceptionMessage("Invalid gravity option, \"" .$gravity. "\" given.\nAvailable: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast" );
81+
7982
$testGravity = new Gravity($gravity);
80-
81-
$message = null;
82-
83-
try {
84-
$testGravity->validate();
85-
} catch (\InvalidArgumentException $e) {
86-
$message = $e->getMessage();
87-
}
88-
89-
static::assertNotNull($message, 'No exception for gravity "'.$gravity.'"');
90-
static::assertStringStartsWith('Invalid gravity option, "'.$gravity.'" given.', $message, "Wrong exception message:\n$message");
83+
$testGravity->validate();
9184
}
9285

9386
public function provideWrongGravities(): ?\Generator

0 commit comments

Comments
 (0)