mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 12:48:28 +08:00
Automatically set up Mockery for unit tests
- Use provided PhpUnit listener to enforce verification of expectations. - Include Mockery's trait to auto-close Mockery after each test.
This commit is contained in:
parent
879b801600
commit
4f1adba387
|
@ -19,4 +19,7 @@
|
|||
<directory suffix=".php">./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener"></listener>
|
||||
</listeners>
|
||||
</phpunit>
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
namespace Flarum\Tests\unit\Foundation\ErrorHandling\ExceptionHandler;
|
||||
|
||||
use Flarum\Foundation\ErrorHandling\ExceptionHandler\IlluminateValidationExceptionHandler;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
use Illuminate\Translation\ArrayLoader;
|
||||
use Illuminate\Translation\Translator;
|
||||
use Illuminate\Validation\Factory;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IlluminateValidationExceptionHandlerTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Flarum\Tests\unit\Foundation\ErrorHandling\ExceptionHandler;
|
|||
|
||||
use Flarum\Foundation\ErrorHandling\ExceptionHandler\ValidationExceptionHandler;
|
||||
use Flarum\Foundation\ValidationException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
|
||||
class ValidationExceptionHandlerTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tests\unit;
|
||||
namespace Flarum\Tests\unit\Install;
|
||||
|
||||
use Flarum\Install\BaseUrl;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
use Zend\Diactoros\Uri;
|
||||
|
||||
class BaseUrlTest extends TestCase
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
namespace Flarum\Tests\unit\Settings;
|
||||
|
||||
use Flarum\Settings\DatabaseSettingsRepository;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Mockery as m;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DatabaseSettingsRepositoryTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace Flarum\Tests\unit\Settings;
|
|||
|
||||
use Flarum\Settings\MemoryCacheSettingsRepository;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
use Mockery as m;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MemoryCacheSettingsRepositoryTest extends TestCase
|
||||
{
|
||||
|
|
20
tests/unit/TestCase.php
Normal file
20
tests/unit/TestCase.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?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;
|
||||
|
||||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
||||
|
||||
abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
// Ensure Mockery is always torn down automatically after each test.
|
||||
use MockeryPHPUnitIntegration;
|
||||
}
|
Loading…
Reference in New Issue
Block a user