cebe / yii2-openapi

REST API application generator for Yii2, openapi 3.0 YAML -> Yii2
MIT License
129 stars 23 forks source link

Foreign key order issue in MySQL tests #150

Closed SOHELAHMED7 closed 1 year ago

SOHELAHMED7 commented 1 year ago

Very much similar to https://github.com/cebe/yii2-openapi/issues/139

One local Mysql test fails which passes in Github action.

$ ./vendor/bin/phpunit --filter MultiDbSecondaryMigrationTest::testMysql
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
PHPUnit 8.5.33 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 1.78 seconds, Memory: 14.00 MB

There was 1 failure:

1) tests\unit\MultiDbSecondaryMigrationTest::testMysql
Failed asserting that file contents of
/app/tests/tmp/docker_app/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
are equal to file contents of
/app/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php 

 cp /app/tests/tmp/docker_app/migrations_mysql_db/m200000_000005_change_table_v2_comments.php /app/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php 

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 {\n
     public function up()\n
     {\n
+        $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');\n
         $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');\n
-        $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');\n
         $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->after('post_id'));\n
         $this->dropColumn('{{%v2_comments}}', 'author_id');\n
         $this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());\n
@@ @@
         $this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');\n
         $this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull());\n
         $this->dropColumn('{{%v2_comments}}', 'user_id');\n
+        $this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');\n
         $this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');\n
-        $this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');\n
     }\n
 }\n
 '

/app/tests/DbTestCase.php:130
/app/tests/DbTestCase.php:105
/app/tests/unit/MultiDbSecondaryMigrationTest.php:68
phpvfscomposer:///app/vendor/phpunit/phpunit/phpunit:97

FAILURES!
Tests: 1, Assertions: 39, Failures: 1.
SOHELAHMED7 commented 1 year ago

# CLI

make clean_all
make up
make migrate

fixed this issue