From f3cbdb5d121acd2fd2104db094598cf1d33f4d84 Mon Sep 17 00:00:00 2001 From: Scott Bouchard Date: Thu, 24 May 2018 14:42:11 -0400 Subject: [PATCH] Call Form::isSubmitted() before Form::isValid() fixes #581 --- Form/Handler/AuthorizeFormHandler.php | 2 +- Tests/Form/Handler/AuthorizeFormHandlerTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Form/Handler/AuthorizeFormHandler.php b/Form/Handler/AuthorizeFormHandler.php index 53924ec7..a4d14774 100644 --- a/Form/Handler/AuthorizeFormHandler.php +++ b/Form/Handler/AuthorizeFormHandler.php @@ -92,7 +92,7 @@ public function process() } $this->form->handleRequest($request); - if (!$this->form->isValid()) { + if ($this->form->isSubmitted() && $this->form->isValid() === false) { return false; } diff --git a/Tests/Form/Handler/AuthorizeFormHandlerTest.php b/Tests/Form/Handler/AuthorizeFormHandlerTest.php index ad652ecf..e4d83152 100644 --- a/Tests/Form/Handler/AuthorizeFormHandlerTest.php +++ b/Tests/Form/Handler/AuthorizeFormHandlerTest.php @@ -369,6 +369,13 @@ public function testProcessWillHandleRequestOnPost() ->willReturn($this->form) ; + $this->form + ->expects($this->once()) + ->method('isSubmitted') + ->with() + ->willReturn(true) + ; + $this->form ->expects($this->once()) ->method('isValid') @@ -428,6 +435,13 @@ public function testProcessWillHandleRequestOnPostAndWillProcessDataIfFormIsVali ->willReturn($this->form) ; + $this->form + ->expects($this->once()) + ->method('isSubmitted') + ->with() + ->willReturn(true) + ; + $this->form ->expects($this->once()) ->method('isValid')