Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve: Add a test for: a column change: data type + comment + position; all 3 are changed #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

return [
'openApiPath' => '@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`
];
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* Table for Fruit
*/
class m200000_000000_change_table_fruits extends \yii\db\Migration
{
public function up()
{
$this->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'));
}
}
23 changes: 23 additions & 0 deletions tests/unit/IssueFixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Loading