Skip to content

Commit

Permalink
tests adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagotalma committed Nov 16, 2023
1 parent af18ff3 commit aff47e9
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions tests/generators/ModelGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()',
Expand All @@ -144,7 +156,9 @@ public function relationsProvider()
'relation' => "\$this->hasOne(Supplier::className(), ['id' => 'supplier_id']);",
'expected' => true,
],
]],
],
true // $fromDestTable
],

['organization', 'Organization.php', false, [
[
Expand All @@ -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, [
Expand All @@ -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;

Expand Down

0 comments on commit aff47e9

Please sign in to comment.