1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 13:40:20 +02:00

Extract pure unit tests so that they can run fast

- Move to separate directory (base for a separate test suite)
- Inherit directly from PhpUnit
- Configure test suite with dedicated XML file
This commit is contained in:
Franz Liedke
2019-01-01 21:11:29 +01:00
parent 6484dc4982
commit ba16ebe61f
13 changed files with 38 additions and 42 deletions

View File

@@ -0,0 +1,46 @@
<?php
/*
* 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.
*/
namespace Flarum\Tests\unit\Api\ExceptionHandler;
use Exception;
use Flarum\Api\ExceptionHandler\ModelNotFoundExceptionHandler;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use PHPUnit\Framework\TestCase;
class ModelNotFoundExceptionHandlerTest extends TestCase
{
private $handler;
public function setUp()
{
$this->handler = new ModelNotFoundExceptionHandler;
}
public function test_it_handles_recognisable_exceptions()
{
$this->assertFalse($this->handler->manages(new Exception));
$this->assertTrue($this->handler->manages(new ModelNotFoundException));
}
public function test_managing_exceptions()
{
$response = $this->handler->handle(new ModelNotFoundException);
$this->assertEquals(404, $response->getStatus());
$this->assertEquals([
[
'status' => '404',
'code' => 'resource_not_found'
]
], $response->getErrors());
}
}