vendor/doctrine-migrations/tests/Doctrine/DBAL/Migrations/Tests/VersionTest.php
author ymh <ymh.work@gmail.com>
Fri, 25 Nov 2011 18:55:43 +0100
changeset 39 03b14b0fe101
permissions -rw-r--r--
Documentation and add alternative wp url and label + migrations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
namespace Doctrine\DBAL\Migrations\Tests;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
use Doctrine\DBAL\Migrations\Tests\MigrationTestCase;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
use Doctrine\DBAL\Schema\Schema;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
use Doctrine\DBAL\Migrations\AbstractMigration;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
use Doctrine\DBAL\Migrations\Version;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
use Doctrine\DBAL\Migrations\Configuration\Configuration;
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
/**
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * Version Test
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 */
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
class VersionTest extends MigrationTestCase
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
{
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    /**
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
     * Create simple migration
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
     */
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    public function testCreateVersion()
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    {
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        $version = new Version(new Configuration($this->getSqliteConnection()), $versionName = '003',
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
            'Doctrine\DBAL\Migrations\Tests\VersionTest_Migration');
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        $this->assertEquals($versionName, $version->getVersion());
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    }
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    /**
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
     * Create migration with custom name
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
     */
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    public function testCreateVersionWithCustomName()
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
    {
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
        $versionName = 'CustomVersionName';
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
        $version = new Version(new Configuration($this->getSqliteConnection()), '003',
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
            'Doctrine\DBAL\Migrations\Tests\VersionTest_MigrationCustom');
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
        $this->assertEquals($versionName, $version->getVersion());
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    }
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
/**
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
 * Simple migration
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
 */
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
class VersionTest_Migration extends AbstractMigration
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
{
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    public function down(Schema $schema) {}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
    public function up(Schema $schema)   {}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
/**
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
 * Migration with custom name
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
 */
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
class VersionTest_MigrationCustom extends AbstractMigration
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
{
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
    public function getName()
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
    {
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
        return 'CustomVersionName';
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
    }
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
    public function down(Schema $schema) {}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
    public function up(Schema $schema)   {}
03b14b0fe101 Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
}