├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── infection.json.dist ├── phpstan.neon ├── phpunit.xml.dist ├── src ├── Comparator │ ├── TopologicalMap.php │ └── TopologicalVersionComparator.php ├── DependencyInjection │ ├── Configuration.php │ └── SyliusLabsDoctrineMigrationsExtraExtension.php ├── Factory │ └── ContainerAwareVersionFactory.php ├── Resources │ └── config │ │ └── services.xml └── SyliusLabsDoctrineMigrationsExtraBundle.php └── tests ├── Comparator └── TopologicalVersionComparatorTest.php ├── DependencyInjection ├── ConfigurationTest.php └── SyliusLabsDoctrineMigrationsExtraExtensionTest.php ├── Factory └── ContainerAwareVersionFactoryTest.php └── Fixture ├── ContainerAwareMigration.php └── NotContainerAwareMigration.php /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches-ignore: 6 | - 'dependabot/**' 7 | pull_request: ~ 8 | release: 9 | types: [created] 10 | schedule: 11 | - 12 | cron: "0 1 * * 6" # Run at 1am every Saturday 13 | workflow_dispatch: ~ 14 | 15 | jobs: 16 | test: 17 | runs-on: ubuntu-20.04 18 | 19 | name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}" 20 | 21 | timeout-minutes: 10 22 | 23 | strategy: 24 | fail-fast: false 25 | matrix: 26 | php: ["8.1", "8.2", "8.3"] 27 | symfony: ["^5.4", "^6.4", "^7.0"] 28 | exclude: 29 | - php: "8.1" 30 | symfony: "^7.0" 31 | 32 | steps: 33 | - uses: actions/checkout@v2 34 | 35 | - name: Setup PHP 36 | uses: shivammathur/setup-php@v2 37 | with: 38 | php-version: "${{ matrix.php }}" 39 | coverage: none 40 | 41 | - name: Get Composer cache directory 42 | id: composer-cache 43 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 44 | 45 | - name: Cache Composer 46 | uses: actions/cache@v2 47 | with: 48 | path: ${{ steps.composer-cache.outputs.dir }} 49 | key: ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer-${{ hashFiles(format('src/Sylius/{0}/composer.json', matrix.package)) }} 50 | restore-keys: | 51 | ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer- 52 | ${{ runner.os }}-php-${{ matrix.php }}-package- 53 | 54 | - name: Restrict Symfony version 55 | if: matrix.symfony != '' 56 | run: | 57 | composer global config --no-plugins allow-plugins.symfony/flex true 58 | composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.17" 59 | composer config extra.symfony.require "${{ matrix.symfony }}" 60 | 61 | - name: Install dependencies 62 | run: composer install --ansi --no-interaction 63 | 64 | - name: Run PHPStan 65 | run: vendor/bin/phpstan analyse 66 | 67 | - name: Run PHPUnit 68 | run: vendor/bin/phpunit 69 | 70 | - name: Run Infection 71 | if: ${{matrix.symfony == '^7.0' }} 72 | run: phpdbg -qrr vendor/bin/infection --min-msi=82 73 | 74 | - name: Run Infection 75 | if: ${{matrix.symfony != '^7.0' }} 76 | run: phpdbg -qrr vendor/bin/infection --min-msi=100 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.result.cache 2 | /composer.lock 3 | /infection.json 4 | /infection.log 5 | /phpunit.xml 6 | /vendor 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Kamil Kokot 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | 7 |

DoctrineMigrationsExtraBundle

8 | 9 | Adding a topological sorter and container injection to DoctrineMigrationsBundle. 10 | 11 | ## Installation 12 | 13 | 1. Require this package in your project: 14 | 15 | ```bash 16 | composer require sylius-labs/doctrine-migrations-extra-bundle 17 | ``` 18 | 19 | 2. Add this bundle to `config/bundles.php`: 20 | 21 | ```php 22 | return [ 23 | // ... 24 | SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], 25 | ]; 26 | ``` 27 | 28 | 3. Replace original Doctrine migrations services with the ones from this bundle by adding the following config in `config/packages/doctrine_migrations.yaml`: 29 | 30 | ```yaml 31 | doctrine_migrations: 32 | services: 33 | 'Doctrine\Migrations\Version\MigrationFactory': 'SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory' 34 | 'Doctrine\Migrations\Version\Comparator': 'SyliusLabs\DoctrineMigrationsExtraBundle\Comparator\TopologicalVersionComparator' 35 | ``` 36 | 37 | ## Usage 38 | 39 | ### In an application 40 | 41 | In order to define the topology of migrations, configure it in `config/packages/sylius_labs_doctrine_migrations_extra.yaml`: 42 | 43 | ```yaml 44 | sylius_labs_doctrine_migrations_extra: 45 | migrations: 46 | 'Core\Migrations': ~ 47 | 'PluginDependingOnCommonPlugin\Migrations': ['Core\Migrations', 'CommonPlugin\Migrations'] 48 | 'CommonPlugin\Migrations': ['Core\Migrations'] 49 | 'PluginDependingOnCore\Migrations': ['Core\Migrations'] 50 | ``` 51 | 52 | The following configuration will result in the following order: 53 | 54 | - `Core\Migrations` 55 | - `CommonPlugin\Migrations` 56 | - `PluginDependingOnCommonPlugin\Migrations` 57 | - `PluginDependingOnCore\Migrations` 58 | 59 | ### In a bundle 60 | 61 | If you want to make your bundle define its dependencies on it own, prepend the configuration in your bundle's extension: 62 | 63 | ```php 64 | use Symfony\Component\DependencyInjection\Extension\Extension; 65 | use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; 66 | 67 | final class AcmeExtension extends Extension implements PrependExtensionInterface 68 | { 69 | // ... 70 | 71 | public function prepend(ContainerBuilder $container): void 72 | { 73 | if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) { 74 | return; 75 | } 76 | 77 | $container->prependExtensionConfig('doctrine_migrations', [ 78 | 'migrations_paths' => [ 79 | 'Acme\AcmeBundle\Migrations' => '@AcmeBundle/Migrations', 80 | ], 81 | ]); 82 | 83 | $container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [ 84 | 'migrations' => [ 85 | 'Acme\AcmeBundle\Migrations' => ['Core\Migrations'], 86 | ], 87 | ]); 88 | } 89 | } 90 | ``` 91 | 92 | ## Generating new diff 93 | 94 | Cause this bundle will dynamically change the configuration of Doctrine Migrations, you may need to specify your own namespace like: 95 | ```yaml 96 | # config/packages/doctrine_migrations.yaml 97 | doctrine_migrations: 98 | migrations_paths: 99 | 'App\Migrations': "%kernel.project_dir%/src/Migrations" 100 | 101 | # config/packages/sylius_labs_doctrine_migrations_extra.yaml 102 | sylius_labs_doctrine_migrations_extra: 103 | migrations: 104 | 'App\Migrations': ~ 105 | ``` 106 | After that you will be able to generate again your own migration by calling: 107 | ```bash 108 | bin/console doctrine:migrations:diff --namespace=App\\Migrations 109 | ``` 110 | 111 | ## Versioning and release cycle 112 | 113 | This package follows [semantic versioning](https://semver.org/). 114 | 115 | Next major releases are not planned yet. Minor and patch releases will be published as needed. 116 | 117 | Bug fixes will be provided only for the most recent minor release. 118 | Security fixes will be provided for one year since the release of subsequent minor release. 119 | 120 | ## License 121 | 122 | This extension is completely free and released under permissive [MIT license](LICENSE). 123 | 124 | ## Authors 125 | 126 | It is originally created by [Kamil Kokot](https://github.com/pamil). 127 | See the list of [all contributors](https://github.com/SyliusLabs/DoctrineMigrationsExtraBundle/graphs/contributors). 128 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sylius-labs/doctrine-migrations-extra-bundle", 3 | "type": "bundle", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "Kamil Kokot", 8 | "email": "kamil@kokot.me", 9 | "homepage": "https://kamilkokot.com" 10 | } 11 | ], 12 | "require": { 13 | "php": "^8.1", 14 | "doctrine/doctrine-migrations-bundle": "^3.0", 15 | "doctrine/migrations": "^3.0", 16 | "marcj/topsort": "^1.1", 17 | "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0" 18 | }, 19 | "require-dev": { 20 | "infection/infection": "^0.28", 21 | "matthiasnoback/symfony-config-test": "^5.1", 22 | "matthiasnoback/symfony-dependency-injection-test": "^5.1", 23 | "phpstan/phpstan": "^1.10", 24 | "phpunit/phpunit": "^9.5" 25 | }, 26 | "config": { 27 | "allow-plugins": { 28 | "symfony/flex": true, 29 | "infection/extension-installer": true 30 | } 31 | }, 32 | "autoload": { 33 | "psr-4": { 34 | "SyliusLabs\\DoctrineMigrationsExtraBundle\\": "src/" 35 | } 36 | }, 37 | "autoload-dev": { 38 | "psr-4": { 39 | "Tests\\SyliusLabs\\DoctrineMigrationsExtraBundle\\": "tests/" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /infection.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "source": { 3 | "directories": [ 4 | "src" 5 | ] 6 | }, 7 | "logs": { 8 | "text": "infection.log" 9 | }, 10 | "mutators": { 11 | "@default": true 12 | } 13 | } -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 6 3 | paths: 4 | - src 5 | - tests 6 | 7 | excludePaths: 8 | - tests/Fixture/ContainerAwareMigration 9 | - tests/Factory/ContainerAwareVersionFactoryTest.php 10 | 11 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ./tests/ 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Comparator/TopologicalMap.php: -------------------------------------------------------------------------------- 1 | > 13 | * 14 | * @var array[] 15 | */ 16 | private $packages; 17 | 18 | /** 19 | * @psalm-var array 20 | * 21 | * @var array 22 | */ 23 | private $dependencies; 24 | 25 | /** 26 | * @psalm-param array> $packages 27 | */ 28 | public function __construct(array $packages) 29 | { 30 | $this->packages = $packages; 31 | $this->dependencies = $this->buildDependencies($this->packages); 32 | } 33 | 34 | public function getPriority(string $package): int 35 | { 36 | if (!array_key_exists($package, $this->dependencies)) { 37 | $this->packages[$package] = []; 38 | $this->dependencies = $this->buildDependencies($this->packages); 39 | } 40 | 41 | return $this->dependencies[$package]; 42 | } 43 | 44 | /** 45 | * @psalm-param array> $packages 46 | * 47 | * @psalm-return array 48 | */ 49 | private function buildDependencies(array $packages): array 50 | { 51 | $sorter = new ArraySort(); 52 | 53 | foreach ($packages as $subject => $dependencies) { 54 | $sorter->add($subject, $dependencies); 55 | } 56 | 57 | /** @psalm-var array $sorted */ 58 | $sorted = $sorter->sort(); 59 | 60 | return array_flip($sorted); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Comparator/TopologicalVersionComparator.php: -------------------------------------------------------------------------------- 1 | > $packages 21 | */ 22 | public function __construct(array $packages) 23 | { 24 | $this->defaultSorter = new AlphabeticalComparator(); 25 | $this->map = new TopologicalMap($packages); 26 | } 27 | 28 | public function compare(Version $a, Version $b): int 29 | { 30 | $prefixA = $this->getNamespacePrefix($a); 31 | $prefixB = $this->getNamespacePrefix($b); 32 | 33 | return $this->map->getPriority($prefixA) <=> $this->map->getPriority($prefixB) ?: $this->defaultSorter->compare($a, $b); 34 | } 35 | 36 | private function getNamespacePrefix(Version $version): string 37 | { 38 | $version = (string) $version; 39 | 40 | return substr($version, 0, strrpos($version, '\\') ?: 0); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | getRootNode(); 19 | 20 | $rootNode 21 | ->children() 22 | ->arrayNode('migrations') 23 | ->useAttributeAsKey('subject') 24 | ->arrayPrototype() 25 | ->performNoDeepMerging() 26 | ->scalarPrototype() 27 | ; 28 | 29 | return $treeBuilder; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtension.php: -------------------------------------------------------------------------------- 1 | $configs 18 | * 19 | * @throws \Exception 20 | */ 21 | public function load(array $configs, ContainerBuilder $container): void 22 | { 23 | $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); 24 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 25 | 26 | $loader->load('services.xml'); 27 | 28 | $container->getDefinition(TopologicalVersionComparator::class)->setArgument(0, $config['migrations']); 29 | } 30 | 31 | /** 32 | * @param array $config 33 | */ 34 | public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface 35 | { 36 | return new Configuration(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Factory/ContainerAwareVersionFactory.php: -------------------------------------------------------------------------------- 1 | migrationFactory = $migrationFactory; 23 | $this->container = $container; 24 | } 25 | 26 | public function createVersion(string $migrationClassName): AbstractMigration 27 | { 28 | $instance = $this->migrationFactory->createVersion($migrationClassName); 29 | 30 | if ( 31 | interface_exists(ContainerAwareInterface::class) 32 | && $instance instanceof ContainerAwareInterface 33 | ) { 34 | $instance->setContainer($this->container); 35 | } 36 | 37 | return $instance; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Resources/config/services.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/SyliusLabsDoctrineMigrationsExtraBundle.php: -------------------------------------------------------------------------------- 1 | ['Core'], 20 | 'Core' => [], 21 | 'Random' => [], 22 | ]); 23 | 24 | $this->assertSorting( 25 | $comparator, 26 | ['Core\\Version1', 'Core\\Version2', 'Addon\\Version1', 'Random\\Version1', 'Version1'], 27 | ['Core\\Version2', 'Version1', 'Random\\Version1', 'Addon\\Version1', 'Core\\Version1'] 28 | ); 29 | } 30 | 31 | /** @test */ 32 | public function it_sorts_versions_by_their_namespace_order(): void 33 | { 34 | $comparator = new TopologicalVersionComparator([ 35 | 'Random' => [], 36 | 'Core' => [], 37 | ]); 38 | 39 | $this->assertSorting( 40 | $comparator, 41 | ['Random\\Version1', 'Core\\Version1', 'Core\\Version2'], 42 | ['Core\\Version2', 'Random\\Version1', 'Core\\Version1'] 43 | ); 44 | } 45 | 46 | /** @test */ 47 | public function it_implicitly_adds_namespaces_by_the_order_they_are_discovered(): void 48 | { 49 | // Comparator: A and B is new 50 | $this->assertSorting( 51 | new TopologicalVersionComparator([]), 52 | ['Core\\Version1', 'Core\\Version2', 'Addon\\Version1', 'Random\\Version1'], 53 | ['Core\\Version2', 'Addon\\Version1', 'Random\\Version1', 'Core\\Version1'] 54 | ); 55 | 56 | // Comparator: A is new, B is known 57 | $this->assertSorting( 58 | new TopologicalVersionComparator(['Registered' => []]), 59 | ['Registered\\Version1', 'Core\\Version1'], 60 | ['Core\\Version1', 'Registered\\Version1'] 61 | ); 62 | 63 | // Comparator: B is new, A is known 64 | $this->assertSorting( 65 | new TopologicalVersionComparator(['Registered' => []]), 66 | ['Registered\\Version1', 'Core\\Version1'], 67 | ['Registered\\Version1', 'Core\\Version1'] 68 | ); 69 | } 70 | 71 | /** @test */ 72 | public function it_supports_migrations_without_namespace(): void 73 | { 74 | $this->assertSorting( 75 | new TopologicalVersionComparator([]), 76 | ['Abc', 'Def', 'Ghi'], 77 | ['Def', 'Ghi', 'Abc'] 78 | ); 79 | } 80 | 81 | /** 82 | * @param string[] $expectedVersions 83 | * @param string[] $actualVersions 84 | */ 85 | private function assertSorting(Comparator $comparator, array $expectedVersions, array $actualVersions): void 86 | { 87 | Assert::assertSame( 88 | array_values($expectedVersions), 89 | array_values($this->sort($comparator, $actualVersions)) 90 | ); 91 | } 92 | 93 | /** 94 | * @param string[] $versions 95 | * 96 | * @return string[] 97 | */ 98 | private function sort(Comparator $comparator, array $versions): array 99 | { 100 | $versions = array_map(static function (string $version): Version { 101 | return new Version($version); 102 | }, $versions); 103 | 104 | uasort($versions, static function (Version $a, Version $b) use ($comparator): int { 105 | return $comparator->compare($a, $b); 106 | }); 107 | 108 | return array_map( 109 | static function (Version $version): string { 110 | return (string) $version; 111 | }, 112 | $versions 113 | ); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /tests/DependencyInjection/ConfigurationTest.php: -------------------------------------------------------------------------------- 1 | assertProcessedConfigurationEquals( 25 | [[]], 26 | ['migrations' => []] 27 | ); 28 | } 29 | 30 | /** @test */ 31 | public function migrations_list_is_empty(): void 32 | { 33 | $this->assertProcessedConfigurationEquals( 34 | [['migrations' => []]], 35 | ['migrations' => []] 36 | ); 37 | } 38 | 39 | /** @test */ 40 | public function migrations_list_includes_an_empty_namespace(): void 41 | { 42 | $this->assertProcessedConfigurationEquals( 43 | [['migrations' => ['Name\\Space' => []]]], 44 | ['migrations' => ['Name\\Space' => []]] 45 | ); 46 | } 47 | 48 | /** @test */ 49 | public function migrations_list_includes_an_empty_namespace_as_null(): void 50 | { 51 | $this->assertProcessedConfigurationEquals( 52 | [['migrations' => ['Name\\Space' => null]]], 53 | ['migrations' => ['Name\\Space' => []]] 54 | ); 55 | } 56 | 57 | /** @test */ 58 | public function migrations_list_includes_namespaces_with_required_namespaces(): void 59 | { 60 | $this->assertProcessedConfigurationEquals( 61 | [['migrations' => ['Name\\Space' => ['Another\\Name\\Space']]]], 62 | ['migrations' => ['Name\\Space' => ['Another\\Name\\Space']]] 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tests/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtensionTest.php: -------------------------------------------------------------------------------- 1 | load(['migrations' => ['Name\\Space\\' => []]]); 17 | 18 | $this->assertContainerBuilderHasServiceDefinitionWithArgument( 19 | TopologicalVersionComparator::class, 20 | 0, 21 | ['Name\\Space\\' => []] 22 | ); 23 | } 24 | 25 | protected function getContainerExtensions(): array 26 | { 27 | return [new SyliusLabsDoctrineMigrationsExtraExtension()]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/Factory/ContainerAwareVersionFactoryTest.php: -------------------------------------------------------------------------------- 1 | = 7) { 24 | $this->markTestSkipped(); 25 | } 26 | 27 | // Arrange 28 | $decoratedFactory = $this->createMock(MigrationFactory::class); 29 | $container = $this->createMock(ContainerInterface::class); 30 | 31 | $factory = new ContainerAwareVersionFactory($decoratedFactory, $container); 32 | 33 | $decoratedFactory->method('createVersion')->willReturn(new ContainerAwareMigration( 34 | $this->createMock(Connection::class), 35 | $this->createMock(LoggerInterface::class) 36 | )); 37 | 38 | // Act 39 | $migration = $factory->createVersion('Some\\Class'); 40 | 41 | // Assert 42 | Assert::assertInstanceOf(ContainerAwareMigration::class, $migration); 43 | Assert::assertInstanceOf(ContainerInterface::class, $migration->getContainer()); 44 | } 45 | 46 | /** @test */ 47 | public function migrations_not_implementing_container_aware_interface_are_not_injected_with_container(): void 48 | { 49 | // Arrange 50 | $decoratedFactory = $this->createMock(MigrationFactory::class); 51 | $container = $this->createMock(ContainerInterface::class); 52 | 53 | $factory = new ContainerAwareVersionFactory($decoratedFactory, $container); 54 | 55 | $decoratedFactory->method('createVersion')->willReturn(new NotContainerAwareMigration( 56 | $this->createMock(Connection::class), 57 | $this->createMock(LoggerInterface::class) 58 | )); 59 | 60 | // Act 61 | $migration = $factory->createVersion('Some\\Class'); 62 | 63 | // Assert 64 | Assert::assertInstanceOf(NotContainerAwareMigration::class, $migration); 65 | Assert::assertNull($migration->getContainer()); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/Fixture/ContainerAwareMigration.php: -------------------------------------------------------------------------------- 1 | container = $container; 25 | } 26 | 27 | public function getContainer(): ?ContainerInterface 28 | { 29 | return $this->container; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Fixture/NotContainerAwareMigration.php: -------------------------------------------------------------------------------- 1 | container = $container; 25 | } 26 | 27 | public function getContainer(): ?ContainerInterface 28 | { 29 | return $this->container; 30 | } 31 | } 32 | --------------------------------------------------------------------------------