diff --git a/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php new file mode 100644 index 00000000..f5db5212 --- /dev/null +++ b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php @@ -0,0 +1,13 @@ + '@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.yml', + 'generateUrls' => false, + 'generateModels' => false, + 'excludeModels' => [ + 'Error', + ], + 'generateControllers' => false, + 'generateMigrations' => true, + 'generateModelFaker' => false, // `generateModels` must be `true` in order to use `generateModelFaker` as `true` +]; diff --git a/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.yml b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.yml new file mode 100644 index 00000000..4132182f --- /dev/null +++ b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.yml @@ -0,0 +1,27 @@ +openapi: 3.0.3 +x-description-is-comment: true +info: + title: 'Add a test for: a column change: data type + comment + position; all 3 are changed #64' + version: 1.0.0 + +components: + schemas: + Fruit: + type: object + properties: + id: + type: integer + description: + type: string + col: + type: string + name: + type: integer + description: new desc + +paths: + '/': + get: + responses: + '200': + description: OK diff --git a/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php new file mode 100644 index 00000000..772ab122 --- /dev/null +++ b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php @@ -0,0 +1,17 @@ +alterColumn('{{%fruits}}', 'name', $this->integer()->null()->defaultValue(null)->after('col')->comment('new desc')); + } + + public function down() + { + $this->alterColumn('{{%fruits}}', 'name', $this->text()->null()->after('id')->comment('desc')); + } +} diff --git a/tests/unit/IssueFixTest.php b/tests/unit/IssueFixTest.php index f1b2bfe8..039f6f75 100644 --- a/tests/unit/IssueFixTest.php +++ b/tests/unit/IssueFixTest.php @@ -962,4 +962,27 @@ public function test63JustColumnNameRename() $this->checkFiles($actualFiles, $expectedFiles); Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute(); } + + public function test64AddATestForAColumnChangeDataTypeCommentPositionAll3AreChanged() + { + Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute(); + Yii::$app->db->createCommand()->createTable('{{%fruits}}', [ + 'id' => 'pk', + 'name' => 'text comment "desc"', + 'description' => 'text', + 'col' => 'text', + ])->execute(); + + $testFile = Yii::getAlias("@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php"); + $this->runGenerator($testFile); + $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [ + 'recursive' => true, + ]); + $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql"), [ + 'recursive' => true, + ]); + $this->checkFiles($actualFiles, $expectedFiles); + $this->runActualMigrations('mysql', 1); + Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute(); + } }