public function testGetAll() { $this->table->applied('1')->willReturn(true); $this->table->applied('2')->willReturn(false); $this->table->applied('3')->willReturn(false); $migrations = $this->resolver->getAll(); $this->assertEquals([['version' => '2', 'class' => 'T4web\\MigrationsTest\\Assets\\Version_2', 'description' => 'Some migration 2', 'applied' => false], ['version' => '3', 'class' => 'T4web\\MigrationsTest\\Assets\\Version_3', 'description' => 'Some migration 3', 'applied' => false]], $migrations->getArrayCopy()); }
public function onDispatch(MvcEvent $e) { if (!$e->getRequest() instanceof ConsoleRequest) { throw new RuntimeException('You can only use this action from a console!'); } $migrations = $this->versionResolver->getAll($e->getRequest()->getParam('all')); $list = []; foreach ($migrations as $m) { $list[] = sprintf("%s %s - %s", $m['applied'] ? '-' : '+', $m['version'], $m['description']); } $response = (empty($list) ? 'No migrations available.' : implode("\n", $list)) . "\n"; $e->setResult($response); return $response; }