Skip to content

Commit 1c86e8e

Browse files
committed
Fix failing tests
1 parent 8b1876f commit 1c86e8e

File tree

3 files changed

+23
-51
lines changed

3 files changed

+23
-51
lines changed

tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/migrations_mysql_db/m200000_000002_delete_table_ubigpks.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ public function down()
1515
$this->createTable('{{%ubigpks}}', [
1616
'id' => $this->bigPrimaryKey()->unsigned(),
1717
'name' => $this->string(150)->null()->defaultValue(null),
18-
'size' => 'enum("x-small", "small", "medium", "large", "x-large") NOT NULL DEFAULT \'x-small\'',
19-
'd' => 'smallint(5) unsigned zerofill NULL DEFAULT NULL',
20-
'e' => 'mediumint(8) unsigned zerofill NULL DEFAULT NULL',
21-
'f' => 'decimal(12,4) NULL DEFAULT NULL',
22-
'dp' => $this->double()->null()->defaultValue(null),
23-
'dp2' => 'double(10,4) NULL DEFAULT NULL',
2418
]);
2519
}
2620
}

tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/models/base/Ubigpk.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
*
88
* @property string $id
99
* @property string $name
10-
* @property string $size
11-
* @property integer $d
12-
* @property integer $e
13-
* @property string $f
14-
* @property double $dp
15-
* @property double $dp2
1610
*
1711
*/
1812
abstract class Ubigpk extends \yii\db\ActiveRecord
@@ -25,22 +19,8 @@ public static function tableName()
2519
public function rules()
2620
{
2721
return [
28-
'trim' => [['name', 'f'], 'trim'],
22+
'trim' => [['name'], 'trim'],
2923
'name_string' => [['name'], 'string', 'max' => 150],
30-
'size_string' => [['size'], 'string'],
31-
'size_in' => [['size'], 'in', 'range' => [
32-
'x-small',
33-
'small',
34-
'medium',
35-
'large',
36-
'x-large',
37-
]],
38-
'size_default' => [['size'], 'default', 'value' => 'x-small'],
39-
'd_integer' => [['d'], 'integer'],
40-
'e_integer' => [['e'], 'integer'],
41-
'f_string' => [['f'], 'string', 'max' => 12],
42-
'dp_double' => [['dp'], 'double'],
43-
'dp2_double' => [['dp2'], 'double'],
4424
];
4525
}
4626
}

tests/unit/IssueFixTest.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -239,48 +239,48 @@ public function testNullableFalseInRequired()
239239
$this->checkFiles($actualFiles, $expectedFiles);
240240
}
241241

242-
// Create migration for drop table if a entire schema is deleted from OpenAPI spec #132
243-
// https://github.com/cebe/yii2-openapi/issues/132
244242
// https://github.com/php-openapi/yii2-openapi/pull/4#discussion_r1688225258
245243
public function testCreateMigrationForDropTable132IndependentTablesDropSort()
246244
{
247245
$testFile = Yii::getAlias("@specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/index.php");
248-
$this->createTablesForCreateMigrationForDropTable132();
246+
247+
Yii::$app->db->createCommand()->createTable('{{%upks}}', [
248+
'id' => 'upk',
249+
'name' => 'string(150)',
250+
])->execute();
251+
Yii::$app->db->createCommand()->createTable('{{%bigpks}}', [
252+
'id' => 'bigpk',
253+
'name' => 'string(150)',
254+
])->execute();
255+
Yii::$app->db->createCommand()->createTable('{{%ubigpks}}', [
256+
'id' => 'ubigpk',
257+
'name' => 'string(150)',
258+
])->execute();
259+
249260
$this->runGenerator($testFile);
250261
$this->runActualMigrations('mysql', 4);
251262

252263
$actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
253-
'recursive' => true,
264+
'recursive' => true,
254265
]);
255266
$expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql"), [
256-
'recursive' => true,
267+
'recursive' => true,
257268
]);
258269
$this->checkFiles($actualFiles, $expectedFiles);
259270

260-
$this->deleteTablesForCreateMigrationForDropTable132();
271+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%ubigpks}}')->execute();
272+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%bigpks}}')->execute();
273+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%upks}}')->execute();
261274
}
262275

263276
// Create migration for drop table if a entire schema is deleted from OpenAPI spec #132
264277
// https://github.com/cebe/yii2-openapi/issues/132
265278
public function testCreateMigrationForDropTable132()
266279
{
267280
$testFile = Yii::getAlias("@specs/issue_fix/132_create_migration_for_drop_table/132_create_migration_for_drop_table.php");
268-
269-
Yii::$app->db->createCommand()->createTable('{{%upks}}', [
270-
'id' => 'upk',
271-
'name' => 'string(150)',
272-
])->execute();
273-
Yii::$app->db->createCommand()->createTable('{{%bigpks}}', [
274-
'id' => 'bigpk',
275-
'name' => 'string(150)',
276-
])->execute();
277-
Yii::$app->db->createCommand()->createTable('{{%ubigpks}}', [
278-
'id' => 'ubigpk',
279-
'name' => 'string(150)',
280-
])->execute();
281-
281+
$this->createTablesForCreateMigrationForDropTable132();
282282
$this->runGenerator($testFile);
283-
$this->runActualMigrations('mysql', 3);
283+
$this->runActualMigrations('mysql', 8);
284284

285285
$actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
286286
'recursive' => true,
@@ -290,9 +290,7 @@ public function testCreateMigrationForDropTable132()
290290
]);
291291
$this->checkFiles($actualFiles, $expectedFiles);
292292

293-
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%bigpks}}')->execute();
294-
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%bigpks}}')->execute();
295-
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%bigpks}}')->execute();
293+
$this->deleteTablesForCreateMigrationForDropTable132();
296294
}
297295

298296
private function createTablesForCreateMigrationForDropTable132()

0 commit comments

Comments
 (0)