VersionTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Doctrine\DBAL\Migrations\Tests;
  3. use Doctrine\DBAL\Migrations\Tests\MigrationTestCase;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\DBAL\Migrations\AbstractMigration;
  6. use Doctrine\DBAL\Migrations\Version;
  7. use Doctrine\DBAL\Migrations\Configuration\Configuration;
  8. /**
  9. * Version Test
  10. */
  11. class VersionTest extends MigrationTestCase
  12. {
  13. /**
  14. * Create simple migration
  15. */
  16. public function testCreateVersion()
  17. {
  18. $version = new Version(new Configuration($this->getSqliteConnection()), $versionName = '003',
  19. 'Doctrine\DBAL\Migrations\Tests\VersionTest_Migration');
  20. $this->assertEquals($versionName, $version->getVersion());
  21. }
  22. /**
  23. * Create migration with custom name
  24. */
  25. public function testCreateVersionWithCustomName()
  26. {
  27. $versionName = 'CustomVersionName';
  28. $version = new Version(new Configuration($this->getSqliteConnection()), '003',
  29. 'Doctrine\DBAL\Migrations\Tests\VersionTest_MigrationCustom');
  30. $this->assertEquals($versionName, $version->getVersion());
  31. }
  32. }
  33. /**
  34. * Simple migration
  35. */
  36. class VersionTest_Migration extends AbstractMigration
  37. {
  38. public function down(Schema $schema) {}
  39. public function up(Schema $schema) {}
  40. }
  41. /**
  42. * Migration with custom name
  43. */
  44. class VersionTest_MigrationCustom extends AbstractMigration
  45. {
  46. public function getName()
  47. {
  48. return 'CustomVersionName';
  49. }
  50. public function down(Schema $schema) {}
  51. public function up(Schema $schema) {}
  52. }