Skip to content

Commit

Permalink
Failing test for #806
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Apr 8, 2019
1 parent bba5d8a commit 7dc4d2b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Doctrine\Migrations\Stopwatch;
use Doctrine\Migrations\Tests\MigrationTestCase;
use Doctrine\Migrations\Tests\Stub\EventVerificationListener;
use Doctrine\Migrations\Tests\Stub\Functional\DryRun\DryRun1;
use Doctrine\Migrations\Tests\Stub\Functional\DryRun\DryRun2;
use Doctrine\Migrations\Tests\Stub\Functional\MigrateAddSqlPostAndPreUpAndDownTest;
use Doctrine\Migrations\Tests\Stub\Functional\MigrateAddSqlTest;
use Doctrine\Migrations\Tests\Stub\Functional\MigrateNotTouchingTheSchema;
Expand Down Expand Up @@ -187,6 +189,20 @@ public function testDryRunMigration() : void
self::assertFalse($migrations['3']->isMigrated());
}

public function testDryRunWithTableCreatedWithSchemaInFirstMigration() : void
{
$this->config->registerMigration('1', DryRun1::class);
$this->config->registerMigration('2', DryRun2::class);

$migratorConfiguration = (new MigratorConfiguration())
->setDryRun(true);

$migrator = $this->createTestMigrator($this->config);
$migrator->migrate('2', $migratorConfiguration);

$schema = $this->config->getConnection()->getSchemaManager()->createSchema();
}

public function testMigrateDownSeveralSteps() : void
{
$this->config->registerMigration('1', MigrationMigrateUp::class);
Expand Down
22 changes: 22 additions & 0 deletions tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Doctrine\Migrations\Tests\Stub\Functional\DryRun;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

class DryRun1 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$table = $schema->createTable('foo');
$table->addColumn('id', 'integer');
}

public function down(Schema $schema) : void
{
$schema->dropTable('foo');
}
}
23 changes: 23 additions & 0 deletions tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Doctrine\Migrations\Tests\Stub\Functional\DryRun;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

class DryRun2 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$table = $schema->getTable('foo');
$table->addColumn('bar', 'string', ['notnull' => false]);
}

public function down(Schema $schema) : void
{
$table = $schema->getTable('foo');
$table->dropColumn('bar');
}
}

0 comments on commit 7dc4d2b

Please sign in to comment.