2015-10-27 22:47:03 +08:00
|
|
|
<?php
|
2016-11-29 13:03:53 +08:00
|
|
|
|
2015-12-05 20:01:33 +08:00
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
|
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2018-03-04 07:01:49 +08:00
|
|
|
namespace Flarum\Tests\Api\ExceptionHandler;
|
2015-10-27 22:47:03 +08:00
|
|
|
|
2015-12-05 20:01:33 +08:00
|
|
|
use Exception;
|
2017-06-24 17:25:07 +08:00
|
|
|
use Flarum\Api\ExceptionHandler\InvalidConfirmationTokenExceptionHandler;
|
2018-03-04 07:01:49 +08:00
|
|
|
use Flarum\Tests\Test\TestCase;
|
2017-06-24 18:55:22 +08:00
|
|
|
use Flarum\User\Exception\InvalidConfirmationTokenException;
|
2015-10-27 22:47:03 +08:00
|
|
|
|
|
|
|
class InvalidConfirmationTokenExceptionHandlerTest extends TestCase
|
|
|
|
{
|
|
|
|
private $handler;
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->handler = new InvalidConfirmationTokenExceptionHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_it_handles_recognisable_exceptions()
|
|
|
|
{
|
2015-12-05 20:01:33 +08:00
|
|
|
$this->assertFalse($this->handler->manages(new Exception));
|
2015-10-27 22:47:03 +08:00
|
|
|
$this->assertTrue($this->handler->manages(new InvalidConfirmationTokenException));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_output()
|
|
|
|
{
|
|
|
|
$response = $this->handler->handle(new InvalidConfirmationTokenException);
|
|
|
|
|
|
|
|
$this->assertEquals(403, $response->getStatus());
|
2015-12-05 20:01:33 +08:00
|
|
|
$this->assertEquals([
|
|
|
|
[
|
|
|
|
'status' => '403',
|
|
|
|
'code' => 'invalid_confirmation_token'
|
|
|
|
]
|
|
|
|
], $response->getErrors());
|
2015-10-27 22:47:03 +08:00
|
|
|
}
|
|
|
|
}
|