Skip to content

Commit

Permalink
Tests: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 11, 2024
1 parent 17068a2 commit 01b7fc7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 109 deletions.
49 changes: 49 additions & 0 deletions tests/Cases/DI/MigrationsExtension.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php declare(strict_types = 1);

namespace Tests\Cases\Unit\DI;

use Contributte\Tester\Toolkit;
use Contributte\Tester\Utils\ContainerBuilder;
use Contributte\Tester\Utils\Neonkit;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Tools\Console\Command\DoctrineCommand;
use Nette\DI\Compiler;
use Nettrine\Migrations\DI\MigrationsExtension;
use Nettrine\Migrations\Version\DbalMigrationFactory;
use Symfony\Component\Console\Application;
use Tester\Assert;

require_once __DIR__ . '/../../bootstrap.php';

Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('migrations', new MigrationsExtension());
$compiler->addConfig(Neonkit::load('
parameters:
appDir: /root
migrations:
directories:
App\Domain: %appDir%/migrations
services:
- Symfony\Component\Console\Application
- Doctrine\DBAL\Driver\Mysqli\Driver
- Doctrine\DBAL\Connection([])
'));
})
->build();

/** @var Configuration $configuration */
$configuration = $container->getByType(Configuration::class);
Assert::equal(['App\\Domain' => '/root/migrations'], $configuration->getMigrationDirectories());

// Console
Assert::count(13, $container->findByType(DoctrineCommand::class));
Assert::count(4, iterator_to_array($container->getByType(Application::class)->getHelperSet()));

/** @var DependencyFactory $dependencyFactory */
$dependencyFactory = $container->getByType(DependencyFactory::class);
Assert::type(DependencyFactory::class, $dependencyFactory);
Assert::type(DbalMigrationFactory::class, $dependencyFactory->getMigrationFactory());
});
109 changes: 0 additions & 109 deletions tests/Cases/Unit/DI/MigrationsExtension.phpt

This file was deleted.

12 changes: 12 additions & 0 deletions tests/Toolkit/Tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types = 1);

namespace Tests\Toolkit;

final class Tests
{

public const APP_PATH = __DIR__ . '/..';
public const TEMP_PATH = __DIR__ . '/../tmp';
public const FIXTURES_PATH = __DIR__ . '/../Mocks';

}

0 comments on commit 01b7fc7

Please sign in to comment.