mirror of
https://github.com/flarum/core.git
synced 2025-07-25 10:41:24 +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:
@@ -11,12 +11,8 @@
|
|||||||
syntaxCheck="false">
|
syntaxCheck="false">
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="installation">
|
<testsuite name="Flarum Unit Tests">
|
||||||
<directory suffix="Test.php">./tests/Install</directory>
|
<directory suffix="Test.php">./unit</directory>
|
||||||
</testsuite>
|
|
||||||
<testsuite name="all">
|
|
||||||
<directory suffix="Test.php">./tests</directory>
|
|
||||||
<exclude>./tests/Install</exclude>
|
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
<filter>
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\FloodingExceptionHandler;
|
use Flarum\Api\ExceptionHandler\FloodingExceptionHandler;
|
||||||
use Flarum\Post\Exception\FloodingException;
|
use Flarum\Post\Exception\FloodingException;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class FloodingExceptionHandlerTest extends TestCase
|
class FloodingExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new FloodingExceptionHandler;
|
$this->handler = new FloodingExceptionHandler;
|
||||||
}
|
}
|
@@ -9,21 +9,21 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler;
|
use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Illuminate\Translation\ArrayLoader;
|
use Illuminate\Translation\ArrayLoader;
|
||||||
use Illuminate\Translation\Translator;
|
use Illuminate\Translation\Translator;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class IlluminateValidationExceptionHandlerTest extends TestCase
|
class IlluminateValidationExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new IlluminateValidationExceptionHandler;
|
$this->handler = new IlluminateValidationExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\Exception\InvalidAccessTokenException;
|
use Flarum\Api\Exception\InvalidAccessTokenException;
|
||||||
use Flarum\Api\ExceptionHandler\InvalidAccessTokenExceptionHandler;
|
use Flarum\Api\ExceptionHandler\InvalidAccessTokenExceptionHandler;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class InvalidAccessTokenExceptionHandlerTest extends TestCase
|
class InvalidAccessTokenExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new InvalidAccessTokenExceptionHandler;
|
$this->handler = new InvalidAccessTokenExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\InvalidConfirmationTokenExceptionHandler;
|
use Flarum\Api\ExceptionHandler\InvalidConfirmationTokenExceptionHandler;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Flarum\User\Exception\InvalidConfirmationTokenException;
|
use Flarum\User\Exception\InvalidConfirmationTokenException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class InvalidConfirmationTokenExceptionHandlerTest extends TestCase
|
class InvalidConfirmationTokenExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new InvalidConfirmationTokenExceptionHandler;
|
$this->handler = new InvalidConfirmationTokenExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\MethodNotAllowedExceptionHandler;
|
use Flarum\Api\ExceptionHandler\MethodNotAllowedExceptionHandler;
|
||||||
use Flarum\Http\Exception\MethodNotAllowedException;
|
use Flarum\Http\Exception\MethodNotAllowedException;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MethodNotAllowedExceptionHandlerTest extends TestCase
|
class MethodNotAllowedExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new MethodNotAllowedExceptionHandler();
|
$this->handler = new MethodNotAllowedExceptionHandler();
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\ModelNotFoundExceptionHandler;
|
use Flarum\Api\ExceptionHandler\ModelNotFoundExceptionHandler;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ModelNotFoundExceptionHandlerTest extends TestCase
|
class ModelNotFoundExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new ModelNotFoundExceptionHandler;
|
$this->handler = new ModelNotFoundExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\PermissionDeniedExceptionHandler;
|
use Flarum\Api\ExceptionHandler\PermissionDeniedExceptionHandler;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Flarum\User\Exception\PermissionDeniedException;
|
use Flarum\User\Exception\PermissionDeniedException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class PermissionDeniedExceptionHandlerTest extends TestCase
|
class PermissionDeniedExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new PermissionDeniedExceptionHandler;
|
$this->handler = new PermissionDeniedExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\RouteNotFoundExceptionHandler;
|
use Flarum\Api\ExceptionHandler\RouteNotFoundExceptionHandler;
|
||||||
use Flarum\Http\Exception\RouteNotFoundException;
|
use Flarum\Http\Exception\RouteNotFoundException;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class RouteNotFoundExceptionHandlerTest extends TestCase
|
class RouteNotFoundExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new RouteNotFoundExceptionHandler();
|
$this->handler = new RouteNotFoundExceptionHandler();
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\TokenMismatchExceptionHandler;
|
use Flarum\Api\ExceptionHandler\TokenMismatchExceptionHandler;
|
||||||
use Flarum\Http\Exception\TokenMismatchException;
|
use Flarum\Http\Exception\TokenMismatchException;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class TokenMismatchExceptionHandlerTest extends TestCase
|
class TokenMismatchExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new TokenMismatchExceptionHandler;
|
$this->handler = new TokenMismatchExceptionHandler;
|
||||||
}
|
}
|
@@ -9,18 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Api\ExceptionHandler;
|
namespace Flarum\Tests\unit\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\ValidationExceptionHandler;
|
use Flarum\Api\ExceptionHandler\ValidationExceptionHandler;
|
||||||
use Flarum\Foundation\ValidationException;
|
use Flarum\Foundation\ValidationException;
|
||||||
use Flarum\Tests\Test\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ValidationExceptionHandlerTest extends TestCase
|
class ValidationExceptionHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->handler = new ValidationExceptionHandler;
|
$this->handler = new ValidationExceptionHandler;
|
||||||
}
|
}
|
@@ -9,19 +9,19 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Settings;
|
namespace Flarum\Tests\unit\Settings;
|
||||||
|
|
||||||
use Flarum\Settings\DatabaseSettingsRepository;
|
use Flarum\Settings\DatabaseSettingsRepository;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DatabaseSettingsRepositoryTest extends TestCase
|
class DatabaseSettingsRepositoryTest extends TestCase
|
||||||
{
|
{
|
||||||
private $connection;
|
private $connection;
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->connection = m::mock(ConnectionInterface::class);
|
$this->connection = m::mock(ConnectionInterface::class);
|
||||||
$this->repository = new DatabaseSettingsRepository($this->connection);
|
$this->repository = new DatabaseSettingsRepository($this->connection);
|
@@ -9,19 +9,19 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Flarum\Tests\Settings;
|
namespace Flarum\Tests\unit\Settings;
|
||||||
|
|
||||||
use Flarum\Settings\MemoryCacheSettingsRepository;
|
use Flarum\Settings\MemoryCacheSettingsRepository;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
use Flarum\Tests\Test\TestCase;
|
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MemoryCacheSettingsRepositoryTest extends TestCase
|
class MemoryCacheSettingsRepositoryTest extends TestCase
|
||||||
{
|
{
|
||||||
private $baseRepository;
|
private $baseRepository;
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
public function init()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->baseRepository = m::mock(SettingsRepositoryInterface::class);
|
$this->baseRepository = m::mock(SettingsRepositoryInterface::class);
|
||||||
$this->repository = new MemoryCacheSettingsRepository($this->baseRepository);
|
$this->repository = new MemoryCacheSettingsRepository($this->baseRepository);
|
Reference in New Issue
Block a user