diff --git a/phpunit.xml b/phpunit.xml index 7cac51242..dc968835d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -25,6 +25,9 @@ src/*/tests + + src/Bridge/*/tests + tests diff --git a/src/Bridge/Dotenv/tests/LoadTest.php b/src/Bridge/Dotenv/tests/LoadTest.php index 8cfc0ebca..2df83802c 100644 --- a/src/Bridge/Dotenv/tests/LoadTest.php +++ b/src/Bridge/Dotenv/tests/LoadTest.php @@ -7,7 +7,6 @@ use Mockery as m; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use PHPUnit\Framework\TestCase; -use Spiral\Boot\AbstractKernel; use Spiral\Boot\Directories; use Spiral\Boot\EnvironmentInterface; use Spiral\DotEnv\Bootloader\DotenvBootloader; @@ -16,33 +15,38 @@ final class LoadTest extends TestCase { use MockeryPHPUnitIntegration; - public function testUseKernelCallback(): void + public function testSetValue(): void { - $d = new Directories(['root' => __DIR__.'/']); + $dirs = new Directories(['root' => __DIR__.'/']); - $e = m::mock(EnvironmentInterface::class); - $e->shouldReceive('get')->once()->withSomeOfArgs('DOTENV_PATH')->andReturn($d->get('root').'.env.custom'); - $e->shouldReceive('set')->once()->with('KEY', 'custom_value'); - - $k = m::mock(AbstractKernel::class); - $k->shouldReceive('running')->once()->andReturnUsing(fn(\Closure $callback) => $callback($e)); + $env = m::mock(EnvironmentInterface::class); + $env + ->shouldReceive('get') + ->once() + ->withSomeOfArgs('DOTENV_PATH') + ->andReturn($dirs->get('root') . '.env.custom'); + $env->shouldReceive('set') + ->once()->with('KEY', 'custom_value'); $b = new DotenvBootloader(); - $b->init($k, $d); + $b->init($dirs, $env); } public function testNotFound(): void { - $d = new Directories(['root' => __DIR__.'/']); - - $e = m::mock(EnvironmentInterface::class); - $e->shouldReceive('get')->once()->withSomeOfArgs('DOTENV_PATH')->andReturn($d->get('root').'.env'); - $e->shouldNotReceive('set')->with('KEY', 'custom_value'); - - $k = m::mock(AbstractKernel::class); - $k->shouldReceive('running')->once()->andReturnUsing(fn(\Closure $callback) => $callback($e)); + $dirs = new Directories(['root' => __DIR__.'/']); + + $env = m::mock(EnvironmentInterface::class); + $env + ->shouldReceive('get') + ->once() + ->withSomeOfArgs('DOTENV_PATH') + ->andReturn($dirs->get('root').'.env'); + $env + ->shouldNotReceive('set') + ->with('KEY', 'custom_value'); $b = new DotenvBootloader(); - $b->init($k, $d); + $b->init($dirs, $env); } } diff --git a/src/Bridge/Monolog/tests/BaseTest.php b/src/Bridge/Monolog/tests/BaseTest.php deleted file mode 100644 index 129a98576..000000000 --- a/src/Bridge/Monolog/tests/BaseTest.php +++ /dev/null @@ -1,21 +0,0 @@ -container = new Container(); - $this->container->bind(EnvironmentInterface::class, new Environment()); - } -} diff --git a/src/Bridge/Monolog/tests/BaseTestCase.php b/src/Bridge/Monolog/tests/BaseTestCase.php new file mode 100644 index 000000000..a6441dc4a --- /dev/null +++ b/src/Bridge/Monolog/tests/BaseTestCase.php @@ -0,0 +1,27 @@ +container = new Container(); + $this->container->bind(EnvironmentInterface::class, new Environment()); + $this->container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); + $this->container->bind(InitializerInterface::class, Initializer::class); + } +} diff --git a/src/Bridge/Monolog/tests/FactoryTest.php b/src/Bridge/Monolog/tests/FactoryTest.php index 141b8778d..62a538e50 100644 --- a/src/Bridge/Monolog/tests/FactoryTest.php +++ b/src/Bridge/Monolog/tests/FactoryTest.php @@ -23,7 +23,7 @@ use Spiral\Monolog\Config\MonologConfig; use Spiral\Monolog\LogFactory; -class FactoryTest extends BaseTest +class FactoryTest extends BaseTestCase { use MockeryPHPUnitIntegration; @@ -108,8 +108,8 @@ public function load(string $section): array ] ]), new ListenerRegistry(), $this->container); - $handler->shouldReceive('reset')->once(); - $processor->shouldReceive('reset')->once(); + $handler->shouldReceive('reset')->twice(); + $processor->shouldReceive('reset')->twice(); $this->container->bind(LogFactory::class, $factory); $this->container->get(StrategyBasedBootloadManager::class)->bootload([MonologBootloader::class]); diff --git a/src/Bridge/Monolog/tests/HandlersTest.php b/src/Bridge/Monolog/tests/HandlersTest.php index d7fd61bad..2d00effa4 100644 --- a/src/Bridge/Monolog/tests/HandlersTest.php +++ b/src/Bridge/Monolog/tests/HandlersTest.php @@ -19,7 +19,7 @@ use Spiral\Monolog\Config\MonologConfig; use Spiral\Monolog\Exception\ConfigException; -class HandlersTest extends BaseTest +class HandlersTest extends BaseTestCase { public function setUp(): void { diff --git a/src/Bridge/Monolog/tests/LoggerTest.php b/src/Bridge/Monolog/tests/LoggerTest.php index bee001296..338204af2 100644 --- a/src/Bridge/Monolog/tests/LoggerTest.php +++ b/src/Bridge/Monolog/tests/LoggerTest.php @@ -18,7 +18,7 @@ use Spiral\Monolog\Bootloader\MonologBootloader; use Spiral\Monolog\LogFactory; -class LoggerTest extends BaseTest +class LoggerTest extends BaseTestCase { use MockeryPHPUnitIntegration; diff --git a/src/Bridge/Monolog/tests/ProcessorsTest.php b/src/Bridge/Monolog/tests/ProcessorsTest.php index 251c5ae76..8948edbf7 100644 --- a/src/Bridge/Monolog/tests/ProcessorsTest.php +++ b/src/Bridge/Monolog/tests/ProcessorsTest.php @@ -17,7 +17,7 @@ use Spiral\Monolog\Config\MonologConfig; use Spiral\Monolog\Exception\ConfigException; -class ProcessorsTest extends BaseTest +class ProcessorsTest extends BaseTestCase { public function setUp(): void { diff --git a/src/Bridge/Monolog/tests/RotateHandlerTest.php b/src/Bridge/Monolog/tests/RotateHandlerTest.php index 93414111c..9ad6bc145 100644 --- a/src/Bridge/Monolog/tests/RotateHandlerTest.php +++ b/src/Bridge/Monolog/tests/RotateHandlerTest.php @@ -14,7 +14,7 @@ use Spiral\Core\Container; use Spiral\Monolog\Bootloader\MonologBootloader; -class RotateHandlerTest extends BaseTest +class RotateHandlerTest extends BaseTestCase { public function testRotateHandler(): void { diff --git a/src/Bridge/Monolog/tests/TraitTest.php b/src/Bridge/Monolog/tests/TraitTest.php index 02ac018e0..57cb374ad 100644 --- a/src/Bridge/Monolog/tests/TraitTest.php +++ b/src/Bridge/Monolog/tests/TraitTest.php @@ -18,7 +18,7 @@ use Spiral\Monolog\Bootloader\MonologBootloader; use Spiral\Monolog\Config\MonologConfig; -class TraitTest extends BaseTest +class TraitTest extends BaseTestCase { use LoggerTrait; diff --git a/src/Bridge/Stempler/tests/BaseTest.php b/src/Bridge/Stempler/tests/BaseTestCase.php similarity index 98% rename from src/Bridge/Stempler/tests/BaseTest.php rename to src/Bridge/Stempler/tests/BaseTestCase.php index 0856e342d..aea9908c8 100644 --- a/src/Bridge/Stempler/tests/BaseTest.php +++ b/src/Bridge/Stempler/tests/BaseTestCase.php @@ -25,7 +25,7 @@ use Spiral\Views\ViewManager; use Spiral\Views\ViewsInterface; -abstract class BaseTest extends TestCase +abstract class BaseTestCase extends TestCase { public const BOOTLOADERS = [ StemplerBootloader::class, diff --git a/src/Bridge/Stempler/tests/CacheTest.php b/src/Bridge/Stempler/tests/CacheTest.php index 9c53df7bf..fbe7f535d 100644 --- a/src/Bridge/Stempler/tests/CacheTest.php +++ b/src/Bridge/Stempler/tests/CacheTest.php @@ -5,12 +5,11 @@ namespace Spiral\Tests\Stempler; use Spiral\Config\ConfiguratorInterface; -use Spiral\Config\PatchInterface; use Spiral\Files\Files; use Spiral\Files\FilesInterface; use Spiral\Views\ViewContext; -class CacheTest extends BaseTest +class CacheTest extends BaseTestCase { /** @var FilesInterface */ protected $files; diff --git a/src/Bridge/Stempler/tests/ConfigTest.php b/src/Bridge/Stempler/tests/ConfigTest.php index ac3ad5ac4..bdd5a14ee 100644 --- a/src/Bridge/Stempler/tests/ConfigTest.php +++ b/src/Bridge/Stempler/tests/ConfigTest.php @@ -16,7 +16,7 @@ use Spiral\Stempler\Directive\RouteDirective; use Spiral\Views\Processor\ContextProcessor; -class ConfigTest extends BaseTest +class ConfigTest extends BaseTestCase { public function testWireConfigString(): void { diff --git a/src/Bridge/Stempler/tests/DirectiveTest.php b/src/Bridge/Stempler/tests/DirectiveTest.php index a84dd8a50..aaaef7128 100644 --- a/src/Bridge/Stempler/tests/DirectiveTest.php +++ b/src/Bridge/Stempler/tests/DirectiveTest.php @@ -8,7 +8,7 @@ use Spiral\Views\Exception\RenderException; use Spiral\Views\ViewContext; -class DirectiveTest extends BaseTest +class DirectiveTest extends BaseTestCase { public function testRenderDirectiveEx(): void { diff --git a/src/Bridge/Stempler/tests/EngineTest.php b/src/Bridge/Stempler/tests/EngineTest.php index 61060f6b7..6db7352b2 100644 --- a/src/Bridge/Stempler/tests/EngineTest.php +++ b/src/Bridge/Stempler/tests/EngineTest.php @@ -9,7 +9,7 @@ use Spiral\Views\Exception\RenderException; use Spiral\Views\ViewContext; -class EngineTest extends BaseTest +class EngineTest extends BaseTestCase { public function testList(): void { diff --git a/src/Bridge/Stempler/tests/FormatTest.php b/src/Bridge/Stempler/tests/FormatTest.php index b88bac850..2e18720dd 100644 --- a/src/Bridge/Stempler/tests/FormatTest.php +++ b/src/Bridge/Stempler/tests/FormatTest.php @@ -6,7 +6,7 @@ use Spiral\Views\ViewContext; -class FormatTest extends BaseTest +class FormatTest extends BaseTestCase { public function testFormatDiv(): void { diff --git a/src/Bridge/Stempler/tests/Processor/NullLocaleProcessorTest.php b/src/Bridge/Stempler/tests/Processor/NullLocaleProcessorTest.php index c5333b38b..44e1a1e1f 100644 --- a/src/Bridge/Stempler/tests/Processor/NullLocaleProcessorTest.php +++ b/src/Bridge/Stempler/tests/Processor/NullLocaleProcessorTest.php @@ -4,10 +4,10 @@ namespace Spiral\Tests\Stempler\Processor; -use Spiral\Tests\Stempler\BaseTest; +use Spiral\Tests\Stempler\BaseTestCase; use Spiral\Views\ViewContext; -final class NullLocaleProcessorTest extends BaseTest +final class NullLocaleProcessorTest extends BaseTestCase { public function testProcess(): void {