diff --git a/tests/generators/ModelGeneratorTest.php b/tests/generators/ModelGeneratorTest.php index a8fbe455e..dabe6e400 100644 --- a/tests/generators/ModelGeneratorTest.php +++ b/tests/generators/ModelGeneratorTest.php @@ -133,6 +133,18 @@ public function relationsProvider() 'expected' => true, ], ]], + ['product_language', 'ProductLanguage.php', false, [ + [ + 'name' => 'function getSupplier()', + 'relation' => "\$this->hasOne(Product::className(), ['supplier_id' => 'supplier_id', 'id' => 'id']);", + 'expected' => true, + ], + [ + 'name' => 'function getSupplier0()', + 'relation' => "\$this->hasOne(Supplier::className(), ['id' => 'supplier_id']);", + 'expected' => true, + ], + ]], ['product_language', 'ProductLanguage.php', false, [ [ 'name' => 'function getProduct()', @@ -144,7 +156,9 @@ public function relationsProvider() 'relation' => "\$this->hasOne(Supplier::className(), ['id' => 'supplier_id']);", 'expected' => true, ], - ]], + ], + true // $fromDestTable + ], ['organization', 'Organization.php', false, [ [ @@ -169,11 +183,20 @@ public function relationsProvider() ]], ['blog_rtl', 'BlogRtl.php', false, [ [ - 'name' => 'function getUserRtl()', + 'name' => 'function getUser()', 'relation' => "\$this->hasOne(UserRtl::className(), ['id' => 'id_user']);", 'expected' => true, ], ]], + ['blog_rtl', 'BlogRtl.php', false, [ + [ + 'name' => 'function getUserRtl()', + 'relation' => "\$this->hasOne(UserRtl::className(), ['id' => 'id_user']);", + 'expected' => true, + ], + ], + true + ], // useClassConstant = true ['category', 'Category.php', true, [ @@ -198,12 +221,12 @@ public function relationsProvider() * @param $useClassConstant bool * @param $relations array */ - public function testRelations($tableName, $fileName, $useClassConstant, $relations) + public function testRelations($tableName, $fileName, $useClassConstant, $relations, $fromDestTable = false) { $generator = new ModelGenerator(); $generator->template = 'default'; $generator->generateRelationsFromCurrentSchema = false; - $generator->generateRelationNameFromDestinationTable = true; + $generator->generateRelationNameFromDestinationTable = $fromDestTable; $generator->useClassConstant = $useClassConstant; $generator->tableName = $tableName;