diff --git a/src/Todo.php b/src/Todo.php index b5629ac..7516b76 100644 --- a/src/Todo.php +++ b/src/Todo.php @@ -5,6 +5,7 @@ namespace MMK2410\MyTodoList; class Todo { const ExceptionMsgInvalidTitle = "Empty task title not allowed"; + const ExceptionMsgInvalidState = "Invalid state tried to set."; private string $title; private string $state; @@ -50,7 +51,7 @@ class Todo $reflect = new \ReflectionClass(TodoStates::class); $constantFound = $reflect->getConstant($state); if ($constantFound === FALSE) { - throw new \InvalidArgumentException("Invalid state tried to set."); + throw new \InvalidArgumentException(self::ExceptionMsgInvalidState); } } } \ No newline at end of file diff --git a/tests/TodoTest.php b/tests/TodoTest.php index e93ff69..1b10605 100644 --- a/tests/TodoTest.php +++ b/tests/TodoTest.php @@ -61,7 +61,7 @@ class TodoTest extends TestCase { $todo = new Todo("stub"); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage("Invalid state tried to set."); + $this->expectExceptionMessage(Todo::ExceptionMsgInvalidState); $todo->setState("bogus"); } }