From b54f56a6831382530f0041540ca18be8de99a825 Mon Sep 17 00:00:00 2001 From: Kirk Bushell Date: Tue, 27 Oct 2015 14:47:03 +0000 Subject: [PATCH] Added tests for invalid confirmation token handling --- ...luminateValidationExceptionHandlerTest.php | 2 +- ...dConfirmationTokenExceptionHandlerTest.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 framework/core/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php diff --git a/framework/core/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/framework/core/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index 2478f4a7b..dac27528d 100644 --- a/framework/core/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/framework/core/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -25,7 +25,7 @@ class IlluminateValidationExceptionHandlerTest extends TestCase public function test_it_creates_the_desired_output() { $this->markTestIncomplete(); - + $exception = new ValidationException(['field' => ['Some error']]); $response = $this->handler->handle($exception); diff --git a/framework/core/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php b/framework/core/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php new file mode 100644 index 000000000..0951581c2 --- /dev/null +++ b/framework/core/tests/Flarum/Api/Handler/InvalidConfirmationTokenExceptionHandlerTest.php @@ -0,0 +1,30 @@ +handler = new InvalidConfirmationTokenExceptionHandler; + } + + public function test_it_handles_recognisable_exceptions() + { + $this->assertFalse($this->handler->manages(new \Exception)); + $this->assertTrue($this->handler->manages(new InvalidConfirmationTokenException)); + } + + public function test_output() + { + $response = $this->handler->handle(new InvalidConfirmationTokenException); + + $this->assertEquals(403, $response->getStatus()); + $this->assertEquals([['code' => 'invalid_confirmation_token']], $response->getErrors()); + } +}