123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- <?php
- /*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
- namespace Doctrine\Tests\DBAL\Schema;
-
- require_once __DIR__ . '/../../TestInit.php';
-
- use Doctrine\DBAL\Schema\Schema,
- Doctrine\DBAL\Schema\Table,
- Doctrine\DBAL\Schema\Column,
- Doctrine\DBAL\Schema\Index,
- Doctrine\DBAL\Schema\Sequence,
- Doctrine\DBAL\Schema\SchemaDiff,
- Doctrine\DBAL\Schema\TableDiff,
- Doctrine\DBAL\Schema\Comparator,
- Doctrine\DBAL\Types\Type,
- Doctrine\DBAL\Schema\ForeignKeyConstraint;
-
- /**
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- * @link www.doctrine-project.org
- * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- * @since 2.0
- * @version $Revision$
- * @author Benjamin Eberlei <kontakt@beberlei.de>
- */
- class ComparatorTest extends \PHPUnit_Framework_TestCase
- {
- public function testCompareSame1()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ),
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer') ),
- )
- ),
- ) );
-
- $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareSame2()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- )
- ),
- ) );
- $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareMissingTable()
- {
- $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
- $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
- $table->setSchemaConfig($schemaConfig);
-
- $schema1 = new Schema( array($table), array(), $schemaConfig );
- $schema2 = new Schema( array(), array(), $schemaConfig );
-
- $expected = new SchemaDiff( array(), array(), array('bugdb' => $table) );
-
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareNewTable()
- {
- $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
- $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
- $table->setSchemaConfig($schemaConfig);
-
- $schema1 = new Schema( array(), array(), $schemaConfig );
- $schema2 = new Schema( array($table), array(), $schemaConfig );
-
- $expected = new SchemaDiff( array('bugdb' => $table), array(), array() );
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareOnlyAutoincrementChanged()
- {
- $column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true));
- $column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false));
-
- $comparator = new Comparator();
- $changedProperties = $comparator->diffColumn($column1, $column2);
-
- $this->assertEquals(array('autoincrement'), $changedProperties);
- }
-
- public function testCompareMissingField()
- {
- $missingColumn = new Column('integerfield1', Type::getType('integer'));
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => $missingColumn,
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(),
- array (
- 'integerfield1' => $missingColumn,
- )
- )
- )
- );
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareNewField()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff ('bugdb',
- array (
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- )
- );
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareChangedColumns_ChangeType()
- {
- $column1 = new Column('charfield1', Type::getType('string'));
- $column2 = new Column('charfield1', Type::getType('integer'));
-
- $c = new Comparator();
- $this->assertEquals(array('type'), $c->diffColumn($column1, $column2));
- $this->assertEquals(array(), $c->diffColumn($column1, $column1));
- }
-
- public function testCompareRemovedIndex()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
- true
- )
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
- true
- )
- )
- ),
- )
- );
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareNewIndex()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
- true
- )
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
- true
- )
- )
- ),
- )
- );
- $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
- }
-
- public function testCompareChangedIndex()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
- true
- )
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array('integerfield1', 'integerfield2'),
- true
- )
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1',
- 'integerfield2'
- ),
- true
- )
- )
- ),
- )
- );
- $actual = Comparator::compareSchemas( $schema1, $schema2 );
- $this->assertEquals($expected, $actual);
- }
-
- public function testCompareChangedIndexFieldPositions()
- {
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true)
- )
- ),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- 'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
- )
- ),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
- )
- ),
- )
- );
- $actual = Comparator::compareSchemas( $schema1, $schema2 );
- $this->assertEquals($expected, $actual);
- }
-
- public function testCompareSequences()
- {
- $seq1 = new Sequence('foo', 1, 1);
- $seq2 = new Sequence('foo', 1, 2);
- $seq3 = new Sequence('foo', 2, 1);
-
- $c = new Comparator();
-
- $this->assertTrue($c->diffSequence($seq1, $seq2));
- $this->assertTrue($c->diffSequence($seq1, $seq3));
- }
-
- public function testRemovedSequence()
- {
- $schema1 = new Schema();
- $seq = $schema1->createSequence('foo');
-
- $schema2 = new Schema();
-
- $c = new Comparator();
- $diffSchema = $c->compare($schema1, $schema2);
-
- $this->assertEquals(1, count($diffSchema->removedSequences));
- $this->assertSame($seq, $diffSchema->removedSequences[0]);
- }
-
- public function testAddedSequence()
- {
- $schema1 = new Schema();
-
- $schema2 = new Schema();
- $seq = $schema2->createSequence('foo');
-
- $c = new Comparator();
- $diffSchema = $c->compare($schema1, $schema2);
-
- $this->assertEquals(1, count($diffSchema->newSequences));
- $this->assertSame($seq, $diffSchema->newSequences[0]);
- }
-
- public function testTableAddForeignKey()
- {
- $tableForeign = new Table("bar");
- $tableForeign->addColumn('id', 'integer');
-
- $table1 = new Table("foo");
- $table1->addColumn('fk', 'integer');
-
- $table2 = new Table("foo");
- $table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($table1, $table2);
-
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- $this->assertEquals(1, count($tableDiff->addedForeignKeys));
- }
-
- public function testTableRemoveForeignKey()
- {
- $tableForeign = new Table("bar");
- $tableForeign->addColumn('id', 'integer');
-
- $table1 = new Table("foo");
- $table1->addColumn('fk', 'integer');
-
- $table2 = new Table("foo");
- $table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($table2, $table1);
-
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- $this->assertEquals(1, count($tableDiff->removedForeignKeys));
- }
-
- public function testTableUpdateForeignKey()
- {
- $tableForeign = new Table("bar");
- $tableForeign->addColumn('id', 'integer');
-
- $table1 = new Table("foo");
- $table1->addColumn('fk', 'integer');
- $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
-
- $table2 = new Table("foo");
- $table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE'));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($table1, $table2);
-
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- $this->assertEquals(1, count($tableDiff->changedForeignKeys));
- }
-
- public function testTablesCaseInsensitive()
- {
- $schemaA = new Schema();
- $schemaA->createTable('foo');
- $schemaA->createTable('bAr');
- $schemaA->createTable('BAZ');
- $schemaA->createTable('new');
-
- $schemaB = new Schema();
- $schemaB->createTable('FOO');
- $schemaB->createTable('bar');
- $schemaB->createTable('Baz');
- $schemaB->createTable('old');
-
- $c = new Comparator();
- $diff = $c->compare($schemaA, $schemaB);
-
- $this->assertSchemaTableChangeCount($diff, 1, 0, 1);
- }
-
- public function testSequencesCaseInsenstive()
- {
- $schemaA = new Schema();
- $schemaA->createSequence('foo');
- $schemaA->createSequence('BAR');
- $schemaA->createSequence('Baz');
- $schemaA->createSequence('new');
-
- $schemaB = new Schema();
- $schemaB->createSequence('FOO');
- $schemaB->createSequence('Bar');
- $schemaB->createSequence('baz');
- $schemaB->createSequence('old');
-
- $c = new Comparator();
- $diff = $c->compare($schemaA, $schemaB);
-
- $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1);
- }
-
- public function testCompareColumnCompareCaseInsensitive()
- {
- $tableA = new Table("foo");
- $tableA->addColumn('id', 'integer');
-
- $tableB = new Table("foo");
- $tableB->addColumn('ID', 'integer');
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertFalse($tableDiff);
- }
-
- public function testCompareIndexBasedOnPropertiesNotName()
- {
- $tableA = new Table("foo");
- $tableA->addColumn('id', 'integer');
- $tableA->addIndex(array("id"), "foo_bar_idx");
-
- $tableB = new Table("foo");
- $tableB->addColumn('ID', 'integer');
- $tableB->addIndex(array("id"), "bar_foo_idx");
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertFalse($tableDiff);
- }
-
- public function testCompareForeignKeyBasedOnPropertiesNotName()
- {
- $tableA = new Table("foo");
- $tableA->addColumn('id', 'integer');
- $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id'));
-
- $tableB = new Table("foo");
- $tableB->addColumn('ID', 'integer');
- $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id'));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertFalse($tableDiff);
- }
-
- public function testCompareForeignKey_RestrictNoAction_AreTheSame()
- {
- $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION'));
- $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT'));
-
- $c = new Comparator();
- $this->assertFalse($c->diffForeignKey($fk1, $fk2));
- }
-
- public function testDetectRenameColumn()
- {
- $tableA = new Table("foo");
- $tableA->addColumn('foo', 'integer');
-
- $tableB = new Table("foo");
- $tableB->addColumn('bar', 'integer');
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertEquals(0, count($tableDiff->addedColumns));
- $this->assertEquals(0, count($tableDiff->removedColumns));
- $this->assertArrayHasKey('foo', $tableDiff->renamedColumns);
- $this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName());
- }
-
- /**
- * You can easily have ambiguouties in the column renaming. If these
- * are detected no renaming should take place, instead adding and dropping
- * should be used exclusively.
- *
- * @group DBAL-24
- */
- public function testDetectRenameColumnAmbiguous()
- {
- $tableA = new Table("foo");
- $tableA->addColumn('foo', 'integer');
- $tableA->addColumn('bar', 'integer');
-
- $tableB = new Table("foo");
- $tableB->addColumn('baz', 'integer');
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertEquals(1, count($tableDiff->addedColumns), "'baz' should be added, not created through renaming!");
- $this->assertArrayHasKey('baz', $tableDiff->addedColumns, "'baz' should be added, not created through renaming!");
- $this->assertEquals(2, count($tableDiff->removedColumns), "'foo' and 'bar' should both be dropped, an ambigouty exists which one could be renamed to 'baz'.");
- $this->assertArrayHasKey('foo', $tableDiff->removedColumns, "'foo' should be removed.");
- $this->assertArrayHasKey('bar', $tableDiff->removedColumns, "'bar' should be removed.");
- $this->assertEquals(0, count($tableDiff->renamedColumns), "no renamings should take place.");
- }
-
- public function testDetectChangeIdentifierType()
- {
- $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.');
-
- $tableA = new Table("foo");
- $tableA->addColumn('id', 'integer', array('autoincrement' => false));
-
- $tableB = new Table("foo");
- $tableB->addColumn('id', 'integer', array('autoincrement' => true));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
-
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- $this->assertArrayHasKey('id', $tableDiff->changedColumns);
- }
-
-
- /**
- * @group DBAL-105
- */
- public function testDiff()
- {
- $table = new \Doctrine\DBAL\Schema\Table('twitter_users');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->addColumn('twitterId', 'integer', array('nullable' => false));
- $table->addColumn('displayName', 'string', array('nullable' => false));
- $table->setPrimaryKey(array('id'));
-
- $newtable = new \Doctrine\DBAL\Schema\Table('twitter_users');
- $newtable->addColumn('id', 'integer', array('autoincrement' => true));
- $newtable->addColumn('twitter_id', 'integer', array('nullable' => false));
- $newtable->addColumn('display_name', 'string', array('nullable' => false));
- $newtable->addColumn('logged_in_at', 'datetime', array('nullable' => true));
- $newtable->setPrimaryKey(array('id'));
-
- $c = new Comparator();
- $tableDiff = $c->diffTable($table, $newtable);
-
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- $this->assertEquals(array('twitterid', 'displayname'), array_keys($tableDiff->renamedColumns));
- $this->assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns));
- $this->assertEquals(0, count($tableDiff->removedColumns));
- }
-
-
- /**
- * @group DBAL-112
- */
- public function testChangedSequence()
- {
- $schema = new Schema();
- $sequence = $schema->createSequence('baz');
-
- $schemaNew = clone $schema;
- /* @var $schemaNew Schema */
- $schemaNew->getSequence('baz')->setAllocationSize(20);
-
- $c = new \Doctrine\DBAL\Schema\Comparator;
- $diff = $c->compare($schema, $schemaNew);
-
- $this->assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz'));
- }
-
- /**
- * @group DBAL-106
- */
- public function testDiffDecimalWithNullPrecision()
- {
- $column = new Column('foo', Type::getType('decimal'));
- $column->setPrecision(null);
-
- $column2 = new Column('foo', Type::getType('decimal'));
-
- $c = new Comparator();
- $this->assertEquals(array(), $c->diffColumn($column, $column2));
- }
-
- /**
- * @param SchemaDiff $diff
- * @param int $newTableCount
- * @param int $changeTableCount
- * @param int $removeTableCount
- */
- public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0)
- {
- $this->assertEquals($newTableCount, count($diff->newTables));
- $this->assertEquals($changeTableCount, count($diff->changedTables));
- $this->assertEquals($removeTableCount, count($diff->removedTables));
- }
-
- /**
- * @param SchemaDiff $diff
- * @param int $newSequenceCount
- * @param int $changeSequenceCount
- * @param int $changeSequenceCount
- */
- public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0)
- {
- $this->assertEquals($newSequenceCount, count($diff->newSequences), "Expected number of new sequences is wrong.");
- $this->assertEquals($changeSequenceCount, count($diff->changedSequences), "Expected number of changed sequences is wrong.");
- $this->assertEquals($removeSequenceCount, count($diff->removedSequences), "Expected number of removed sequences is wrong.");
- }
- }
|