Skip to content

Commit f998279

Browse files
committed
Add test to ensure existing comments are preserved
1 parent 2fb2d7b commit f998279

File tree

2 files changed

+25
-0
lines changed
  • tests

2 files changed

+25
-0
lines changed

tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/index.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ components:
2020
type: string
2121
x-db-type: varchar
2222
description: desc 2
23+
Animal:
24+
type: object
25+
properties:
26+
id:
27+
type: integer
28+
name:
29+
type: integer
30+
description: desc
2331

2432
paths:
2533
'/':

tests/unit/IssueFixTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ public function test158BugGiiapiGeneratedRulesEnumWithTrim()
364364
// https://github.com/php-openapi/yii2-openapi/issues/60
365365
public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment()
366366
{
367+
$this->deleteTableFor60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment();
368+
$this->createTableFor60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment();
367369
$testFile = Yii::getAlias("@specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/index.php");
368370
$this->runGenerator($testFile);
369371
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
@@ -373,5 +375,20 @@ public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnC
373375
// 'recursive' => true,
374376
// ]);
375377
// $this->checkFiles($actualFiles, $expectedFiles);
378+
379+
$this->deleteTableFor60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment();
380+
}
381+
382+
private function createTableFor60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment()
383+
{
384+
Yii::$app->db->createCommand()->createTable('{{%animals}}', [
385+
'id' => 'pk',
386+
'name' => 'text comment "the name"',
387+
])->execute();
388+
}
389+
390+
private function deleteTableFor60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnComment()
391+
{
392+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%animals}}')->execute();
376393
}
377394
}

0 commit comments

Comments
 (0)