public function testSave() { $version = '1'; $this->tableGataway->insert(['version' => $version])->willReturn(null); $this->tableGataway->getLastInsertValue()->willReturn(3); $lastInsertedId = $this->table->save($version); $this->assertEquals(3, $lastInsertedId); }
protected function applyMigration(array $migration, $down = false) { try { /** @var $migrationObject AbstractMigration */ $migrationObject = new $migration['class']($this->serviceLocator); $this->console->writeLine(sprintf("%s Execute migration class %s.", $migration['class'], $down ? 'down' : 'up')); if ($down) { $migrationObject->down(); $this->versionTable->delete($migration['version']); } else { $migrationObject->up(); $this->versionTable->save($migration['version']); } } catch (InvalidQueryException $e) { $previousMessage = $e->getPrevious() ? $e->getPrevious()->getMessage() : null; $msg = sprintf('%s: "%s"; File: %s; Line #%d', $e->getMessage(), $previousMessage, $e->getFile(), $e->getLine()); throw new \Exception($msg, $e->getCode(), $e); } catch (\Exception $e) { $msg = sprintf('%s; File: %s; Line #%d', $e->getMessage(), $e->getFile(), $e->getLine()); throw new \Exception($msg, $e->getCode(), $e); } }