Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 3fff89a

Browse files
committed
Fix #107
1 parent a6c20ef commit 3fff89a

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

tests/DbTestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ protected function runActualMigrations(string $db = 'mysql', int $number = 2): v
113113
$lastThird = count($upOutput) - 3;
114114
$this->assertSame($upExitCode, 0);
115115
$this->assertSame($upOutput[$last], 'Migrated up successfully.');
116-
$this->assertSame($upOutput[$lastThird], $number.' migrations were applied.');
116+
$this->assertSame($upOutput[$lastThird], $number.' '.(($number === 1) ? 'migration was' : 'migrations were').' applied.');
117117
// 1 migration was applied.
118+
// 2 migrations were applied.
118119

119120
// down
120121
exec('cd tests; ./yii migrate-'.$db.'/down --interactive=0 '.$number, $downOutput, $downExitCode);
121122
$last = count($downOutput) - 1;
122123
$lastThird = count($downOutput) - 3;
123124
$this->assertSame($downExitCode, 0);
124125
$this->assertSame($downOutput[$last], 'Migrated down successfully.');
125-
$this->assertSame($downOutput[$lastThird], $number.' migrations were reverted.');
126+
$this->assertSame($downOutput[$lastThird], $number.' '.(($number === 1) ? 'migration was' : 'migrations were').' reverted.');
126127

127128
}
128129
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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->db->createCommand('ALTER TABLE {{%fruits}} ADD COLUMN test_emails json NOT NULL')->execute();
11+
$this->alterColumn('{{%fruits}}', 'name', $this->text()->notNull());
12+
}
13+
14+
public function down()
15+
{
16+
$this->alterColumn('{{%fruits}}', 'name', $this->string(255)->null()->defaultValue(null));
17+
$this->dropColumn('{{%fruits}}', 'test_emails');
18+
}
19+
}

tests/specs/issue_fix/no_syntax_error_107/mysql/no_syntax_error_107.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ components:
2929
# default: '{}'
3030

3131
type: array
32-
x-db-type: text[]
32+
x-db-type: text
3333
nullable: false
3434
# default: '{}'
3535

tests/unit/IssueFixTest.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,22 @@
99
// This class contains tests for various issues present at GitHub
1010
class IssueFixTest extends DbTestCase
1111
{
12-
// TODO WIP resume from here
1312
// fix https://github.com/cebe/yii2-openapi/issues/107
1413
// 107_no_syntax_error
1514
public function testMigrationsAreNotGeneratedWithSyntaxError()
1615
{
17-
// $testFile = Yii::getAlias("@specs/issue_fix/no_syntax_error_107/mysql/no_syntax_error_107.php");
18-
// $this->runGenerator($testFile, 'mysql');
19-
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
20-
// 'recursive' => true,
21-
// ]);
22-
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/id_not_in_rules/app"), [
23-
// 'recursive' => true,
24-
// ]);
25-
// $this->checkFiles($actualFiles, $expectedFiles);
26-
27-
// $this->changeDbToMariadb();
28-
// $this->deleteTablesForNoSyntaxError107();
29-
// $this->createTableForNoSyntaxError107();
30-
// $testFile = Yii::getAlias("@specs/issue_fix/no_syntax_error_107/mysql/no_syntax_error_107.php");
31-
// $this->runGenerator($testFile, 'maria');
32-
33-
$this->changeDbToPgsql();
16+
$testFile = Yii::getAlias("@specs/issue_fix/no_syntax_error_107/mysql/no_syntax_error_107.php");
3417
$this->deleteTablesForNoSyntaxError107();
3518
$this->createTableForNoSyntaxError107();
36-
$testFile = Yii::getAlias("@specs/issue_fix/no_syntax_error_107/mysql/no_syntax_error_107.php");
37-
$this->runGenerator($testFile, 'pgsql');
19+
$this->runGenerator($testFile, 'mysql');
20+
$actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
21+
'recursive' => true,
22+
]);
23+
$expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/no_syntax_error_107/mysql/app"), [
24+
'recursive' => true,
25+
]);
26+
$this->checkFiles($actualFiles, $expectedFiles);
27+
$this->runActualMigrations('mysql', 1);
3828
}
3929

4030
private function deleteTablesForNoSyntaxError107()

0 commit comments

Comments
 (0)