/** * @return MigrationManager */ protected function migrationManager() { if ($this->migrationManager === null) { $this->migrationManager = new MigrationManager($this->migrationStore, $this->migrationsDirectory); $this->migrationManager->registerMigrationsFromDirectory(); } return $this->migrationManager; }
/** * Test RegisterMigrationsFromDirectory method. */ public function testRegisterMigrationsFromDirectory() { $this->given($manager = new MigrationManager(new InMemoryMigrationStore(), __DIR__ . '/../../../Fixtures/Foo'))->then()->variable($manager->nextAvailableVersion())->isNull()->variable($manager->nextMigrationToExecute())->isNull()->exception(function () use($manager) { $manager->registerMigrationsFromDirectory(); })->isInstanceOf(\RuntimeException::class); $this->given($manager = new MigrationManager(new InMemoryMigrationStore(), __DIR__ . '/../../../Fixtures/InvalidMigrations/WithoutMigrationClass'))->then()->exception(function () use($manager) { $manager->registerMigrationsFromDirectory(); })->isInstanceOf(\UnexpectedValueException::class); $this->given($manager = new MigrationManager(new InMemoryMigrationStore(), __DIR__ . '/../../../Fixtures/InvalidMigrations/WithInvalidName'))->then()->exception(function () use($manager) { $manager->registerMigrationsFromDirectory(); })->isInstanceOf(\RuntimeException::class); }