diff --git a/src/Migration/AbstractPdoMigration.php b/src/Migration/AbstractPdoMigration.php index adb7906..5149e84 100644 --- a/src/Migration/AbstractPdoMigration.php +++ b/src/Migration/AbstractPdoMigration.php @@ -53,7 +53,7 @@ abstract protected function doDown(): void; * Add SQL * * @param string $sql - * @param array $parameters + * @param array $parameters */ final protected function addSql(string $sql, array $parameters = []): void { @@ -63,7 +63,7 @@ final protected function addSql(string $sql, array $parameters = []): void /** * Execute SQL entry. * - * @param array{"0": string, "1": array, "2": string} $entry + * @param array{"0": string, "1": array, "2": string} $entry * * @throws MigrationFailedException */ diff --git a/tests/Functional/Console/ExecuteMigrationCommandTest.php b/tests/Functional/Console/ExecuteMigrationCommandTest.php index 5dc0138..30a4afd 100644 --- a/tests/Functional/Console/ExecuteMigrationCommandTest.php +++ b/tests/Functional/Console/ExecuteMigrationCommandTest.php @@ -65,8 +65,9 @@ public function shouldSuccessExecuteDown(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } } diff --git a/tests/Functional/Console/MigrateCommandTest.php b/tests/Functional/Console/MigrateCommandTest.php index 2e34816..0f86f40 100644 --- a/tests/Functional/Console/MigrateCommandTest.php +++ b/tests/Functional/Console/MigrateCommandTest.php @@ -54,8 +54,9 @@ public function shouldSuccessUp(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla', 'active' => 1], - ['id' => 2, 'label' => 'Foo Bar', 'active' => 1], + ['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null], ], $rows); } @@ -80,8 +81,9 @@ public function shouldSuccessUpToSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } @@ -127,8 +129,9 @@ public function shouldSuccessDownToSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } diff --git a/tests/Functional/Migrator/MigratorMySqlTest.php b/tests/Functional/Migrator/MigratorMySqlTest.php index 1699439..82195d2 100644 --- a/tests/Functional/Migrator/MigratorMySqlTest.php +++ b/tests/Functional/Migrator/MigratorMySqlTest.php @@ -57,8 +57,9 @@ public function shouldSuccessUp(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla', 'active' => 1], - ['id' => 2, 'label' => 'Foo Bar', 'active' => 1], + ['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null], ], $rows); } @@ -83,8 +84,9 @@ public function shouldSuccessUpToSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } @@ -98,8 +100,9 @@ public function shouldSuccessDownToSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } @@ -113,8 +116,9 @@ public function shouldSuccessExecuteSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla', 'active' => 1], - ['id' => 2, 'label' => 'Foo Bar', 'active' => 1], + ['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null], ], $rows); $this->migrator->execute(MigrateDirection::Down, '03'); @@ -122,8 +126,9 @@ public function shouldSuccessExecuteSpecificVersion(): void $rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC'); self::assertEquals([ - ['id' => 1, 'label' => 'Bla Bla'], - ['id' => 2, 'label' => 'Foo Bar'], + ['id' => 1, 'label' => 'Bla Bla', 'description' => null], + ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'], + ['id' => 3, 'label' => 'Bar Bar', 'description' => null], ], $rows); } diff --git a/tests/Migrations/DataSet02/Version01.php b/tests/Migrations/DataSet02/Version01.php index 3c00dd3..32cd210 100644 --- a/tests/Migrations/DataSet02/Version01.php +++ b/tests/Migrations/DataSet02/Version01.php @@ -26,7 +26,8 @@ protected function doUp(): void { $this->addSql('CREATE TABLE test_1 ( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, - label VARCHAR(255) NOT NULL + label VARCHAR(255) NOT NULL, + description VARCHAR(255) DEFAULT NULL ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); } diff --git a/tests/Migrations/DataSet02/Version02.php b/tests/Migrations/DataSet02/Version02.php index 509ff6d..c590732 100644 --- a/tests/Migrations/DataSet02/Version02.php +++ b/tests/Migrations/DataSet02/Version02.php @@ -25,7 +25,8 @@ public function getDescription(): string protected function doUp(): void { $this->addSql('INSERT INTO test_1 (id, label) VALUES (?, ?)', [1, 'Bla Bla']); - $this->addSql('INSERT INTO test_1 (id, label) VALUES (:id, :label)', ['id' => 2, 'label' => 'Foo Bar']); + $this->addSql('INSERT INTO test_1 (id, label, description) VALUES (:id, :label, :description)', ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description']); + $this->addSql('INSERT INTO test_1 (id, label, description) VALUES (:id, :label, :description)', ['id' => 3, 'label' => 'Bar Bar', 'description' => null]); } protected function doDown(): void