Skip to content

Commit 914b858

Browse files
authored
Merge pull request #73 from php-openapi/64-add-a-test-for-a-column-change-data-type-+-comment-+-position-all-3-are-changed
Resolve: Add a test for: a column change: data type + comment + position; all 3 are changed
2 parents 3b4dbda + bb0ce8b commit 914b858

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
'openApiPath' => '@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.yml',
5+
'generateUrls' => false,
6+
'generateModels' => false,
7+
'excludeModels' => [
8+
'Error',
9+
],
10+
'generateControllers' => false,
11+
'generateMigrations' => true,
12+
'generateModelFaker' => false, // `generateModels` must be `true` in order to use `generateModelFaker` as `true`
13+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
openapi: 3.0.3
2+
x-description-is-comment: true
3+
info:
4+
title: 'Add a test for: a column change: data type + comment + position; all 3 are changed #64'
5+
version: 1.0.0
6+
7+
components:
8+
schemas:
9+
Fruit:
10+
type: object
11+
properties:
12+
id:
13+
type: integer
14+
description:
15+
type: string
16+
col:
17+
type: string
18+
name:
19+
type: integer
20+
description: new desc
21+
22+
paths:
23+
'/':
24+
get:
25+
responses:
26+
'200':
27+
description: OK
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/**
4+
* Table for Fruit
5+
*/
6+
class m200000_000000_change_table_fruits extends \yii\db\Migration
7+
{
8+
public function up()
9+
{
10+
$this->alterColumn('{{%fruits}}', 'name', $this->integer()->null()->defaultValue(null)->after('col')->comment('new desc'));
11+
}
12+
13+
public function down()
14+
{
15+
$this->alterColumn('{{%fruits}}', 'name', $this->text()->null()->after('id')->comment('desc'));
16+
}
17+
}

tests/unit/IssueFixTest.php

+23
Original file line numberDiff line numberDiff line change
@@ -962,4 +962,27 @@ public function test63JustColumnNameRename()
962962
$this->checkFiles($actualFiles, $expectedFiles);
963963
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
964964
}
965+
966+
public function test64AddATestForAColumnChangeDataTypeCommentPositionAll3AreChanged()
967+
{
968+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
969+
Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
970+
'id' => 'pk',
971+
'name' => 'text comment "desc"',
972+
'description' => 'text',
973+
'col' => 'text',
974+
])->execute();
975+
976+
$testFile = Yii::getAlias("@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php");
977+
$this->runGenerator($testFile);
978+
$actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
979+
'recursive' => true,
980+
]);
981+
$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"), [
982+
'recursive' => true,
983+
]);
984+
$this->checkFiles($actualFiles, $expectedFiles);
985+
$this->runActualMigrations('mysql', 1);
986+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
987+
}
965988
}

0 commit comments

Comments
 (0)