-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from byjg/2.0.1
Fix problem with versions greater than 10.
- Loading branch information
Showing
36 changed files
with
209 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace ByJG\DbMigration\Exception; | ||
|
||
class InvalidMigrationFile extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
namespace Test; | ||
|
||
use ByJG\AnyDataset\Store\PdoMysql; | ||
use ByJG\DbMigration\Migration; | ||
use ByJG\Util\Uri; | ||
|
||
// backward compatibility | ||
if (!class_exists('\PHPUnit\Framework\TestCase')) { | ||
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); | ||
} | ||
|
||
class MigrationTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var Migration | ||
*/ | ||
protected $object; | ||
|
||
public function setUp() | ||
{ | ||
$this->object = new Migration(new Uri('mysql://localhost'), __DIR__ . '/dirstructure'); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$this->object = null; | ||
} | ||
|
||
public function testGetBaseSql() | ||
{ | ||
$base = $this->object->getBaseSql(); | ||
$this->assertEquals(__DIR__ . '/dirstructure/base.sql', $base); | ||
} | ||
|
||
/** | ||
* @expectedException \ByJG\DbMigration\Exception\InvalidMigrationFile | ||
*/ | ||
public function testGetBaseSqlNotFound() | ||
{ | ||
$this->object = new Migration(new Uri('mysql://localhost'), __DIR__ . '/invalid'); | ||
$this->object->getBaseSql(); | ||
} | ||
|
||
public function testGetMigrationSql1() | ||
{ | ||
$version = $this->object->getMigrationSql(1, 1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00001.sql', $version); | ||
} | ||
|
||
public function testGetMigrationSql2() | ||
{ | ||
$version = $this->object->getMigrationSql(2, 1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00002.sql', $version); | ||
} | ||
|
||
public function testGetMigrationSql3() | ||
{ | ||
$version = $this->object->getMigrationSql(12, 1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/up/00012-dev.sql', $version); | ||
} | ||
|
||
/** | ||
* @expectedException \ByJG\DbMigration\Exception\InvalidMigrationFile | ||
* @expectedExceptionMessage version number '13' | ||
*/ | ||
public function testGetMigrationSql4() | ||
{ | ||
$this->object->getMigrationSql(13, 1); | ||
} | ||
|
||
public function testGetMigrationSqlDown1() | ||
{ | ||
$version = $this->object->getMigrationSql(1, -1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00001.sql', $version); | ||
} | ||
|
||
public function testGetMigrationSqlDown2() | ||
{ | ||
$version = $this->object->getMigrationSql(2, -1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00002.sql', $version); | ||
} | ||
|
||
public function testGetMigrationSqlDown3() | ||
{ | ||
$version = $this->object->getMigrationSql(12, -1); | ||
$this->assertEquals(__DIR__ . '/dirstructure/migrations/down/00012-dev.sql', $version); | ||
} | ||
|
||
/** | ||
* @expectedException \ByJG\DbMigration\Exception\InvalidMigrationFile | ||
* @expectedExceptionMessage version number '13' | ||
*/ | ||
public function testGetMigrationSqlDown4() | ||
{ | ||
$this->object->getMigrationSql(13, -1); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.