Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding running bridges tests to phpunit.xml config #993

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<testsuite name="Components Test Suite">
<directory suffix="Test.php">src/*/tests</directory>
</testsuite>
<testsuite name="Bridges Test Suite">
<directory suffix="Test.php">src/Bridge/*/tests</directory>
</testsuite>
<testsuite name="Framework Test Suite">
<directory>tests</directory>
</testsuite>
Expand Down
42 changes: 23 additions & 19 deletions src/Bridge/Dotenv/tests/LoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
21 changes: 0 additions & 21 deletions src/Bridge/Monolog/tests/BaseTest.php

This file was deleted.

27 changes: 27 additions & 0 deletions src/Bridge/Monolog/tests/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Spiral\Tests\Monolog;

use PHPUnit\Framework\TestCase;
use Spiral\Boot\Environment;
use Spiral\Boot\EnvironmentInterface;
use Spiral\Boot\BootloadManager\DefaultInvokerStrategy;
use Spiral\Boot\BootloadManager\Initializer;
use Spiral\Boot\BootloadManager\InitializerInterface;
use Spiral\Boot\BootloadManager\InvokerStrategyInterface;
use Spiral\Core\Container;

abstract class BaseTestCase extends TestCase
{
protected Container $container;

protected function setUp(): void
{
$this->container = new Container();
$this->container->bind(EnvironmentInterface::class, new Environment());
$this->container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
$this->container->bind(InitializerInterface::class, Initializer::class);
}
}
6 changes: 3 additions & 3 deletions src/Bridge/Monolog/tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Spiral\Monolog\Config\MonologConfig;
use Spiral\Monolog\LogFactory;

class FactoryTest extends BaseTest
class FactoryTest extends BaseTestCase
{
use MockeryPHPUnitIntegration;

Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Monolog/tests/HandlersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Monolog/tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Spiral\Monolog\Bootloader\MonologBootloader;
use Spiral\Monolog\LogFactory;

class LoggerTest extends BaseTest
class LoggerTest extends BaseTestCase
{
use MockeryPHPUnitIntegration;

Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Monolog/tests/ProcessorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Monolog/tests/RotateHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Monolog/tests/TraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Spiral\Monolog\Bootloader\MonologBootloader;
use Spiral\Monolog\Config\MonologConfig;

class TraitTest extends BaseTest
class TraitTest extends BaseTestCase
{
use LoggerTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/Bridge/Stempler/tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Stempler/tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Stempler/tests/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Stempler/tests/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Stempler/tests/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Spiral\Views\ViewContext;

class FormatTest extends BaseTest
class FormatTest extends BaseTestCase
{
public function testFormatDiv(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading