Ejemplo n.º 1
0
 public function testApplySqlPatchReturnsPatchWithErrorStatusOnExceptionInSql()
 {
     vfsStream::setup('test', null, array('name.sql' => 'SELE'));
     $patchFile = DBPatcher\PatchFile::createFromFS('name.sql', vfsStream::url('test'));
     /** @var \Doctrine\DBAL\SQLParserUtils Connection $c */
     $connection = m::mock();
     $connection->shouldReceive('beginTransaction')->once();
     $connection->shouldReceive('exec')->with('SELE')->once()->andThrow('\\Doctrine\\DBAL\\DBALException', 'Error test');
     $connection->shouldReceive('rollBack')->once();
     list($patch, $errorMsg) = applySqlPatch($patchFile, $connection);
     $this->assertSame('Error test', $errorMsg);
     $this->assertInstanceOf('\\DBPatcher\\PatchFile', $patch);
     $this->assertSame(DBPatcher\PatchFile::STATUS_ERROR, $patch->status);
 }
Ejemplo n.º 2
0
 private static function setupPatchFile($dir = 'testDir', $name = 'test-patch.sql', $content = 'DROP TABLE some')
 {
     vfsStream::setup($dir, null, array($name => $content));
     return PatchFile::createFromFS($name, vfsStream::url($dir));
 }