/** * @return Status */ public function status() { // executed migration count $numExecutedMigrations = $this->migrationManager()->numberOfMigrations(); // available migration count $availableMigrations = $this->migrationManager->availableVersions(); $numAvailableMigrations = count($availableMigrations); // new migration count $numNewMigrations = $numAvailableMigrations - $numExecutedMigrations; return new Status($this->migrationManager->latestAvailableVersion(), $this->migrationManager->nextAvailableVersion(), $this->migrationManager->latestMigration(), $numExecutedMigrations, $numAvailableMigrations, $numNewMigrations); }
/** * 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); }