Skip to content

Commit 6f2d85f

Browse files
committed
Fix failing test - RelationsInFakerTest::testIndex
1 parent 5104312 commit 6f2d85f

File tree

10 files changed

+39
-6
lines changed

10 files changed

+39
-6
lines changed

src/lib/SchemaToDatabase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ public function prepareModels(): array
125125
}
126126
}
127127

128-
// TODO generate inverse relations
129-
130128
return $models;
131129
}
132130

src/lib/items/DbModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DbModel extends BaseObject
6262
public array $many2many = [];
6363

6464
/**
65-
* @var array|AttributeRelation[] inverse relations # TODO
65+
* @var array|AttributeRelation[] inverse relations
6666
*/
6767
public array $inverseRelations = [];
6868

tests/specs/relations_in_faker/app/models/base/A123.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ public function getB123()
3232
{
3333
return $this->hasOne(\app\models\B123::class, ['id' => 'b123_id']);
3434
}
35+
36+
public function getRouting()
37+
{
38+
return $this->hasOne(\app\models\Routing::class, ['a123_id' => 'id'])->inverseOf('a123');
39+
}
3540
}

tests/specs/relations_in_faker/app/models/base/Account.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ public function rules()
2424
'name_string' => [['name'], 'string', 'max' => 40],
2525
];
2626
}
27+
28+
public function getDomain()
29+
{
30+
return $this->hasOne(\app\models\Domain::class, ['account_id' => 'id'])->inverseOf('account');
31+
}
2732
}

tests/specs/relations_in_faker/app/models/base/B123.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ public function getC123()
3232
{
3333
return $this->hasOne(\app\models\C123::class, ['id' => 'c123_id']);
3434
}
35+
36+
public function getA123()
37+
{
38+
return $this->hasOne(\app\models\A123::class, ['b123_id' => 'id'])->inverseOf('b123');
39+
}
40+
41+
public function getE1232()
42+
{
43+
return $this->hasOne(\app\models\E123::class, ['b123_id' => 'id'])->inverseOf('b123');
44+
}
3545
}

tests/specs/relations_in_faker/app/models/base/C123.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public function rules()
2323
'name_string' => [['name'], 'string'],
2424
];
2525
}
26+
27+
public function getB123()
28+
{
29+
return $this->hasOne(\app\models\B123::class, ['c123_id' => 'id'])->inverseOf('c123');
30+
}
2631
}

tests/specs/relations_in_faker/app/models/base/D123.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public function rules()
2323
'name_string' => [['name'], 'string'],
2424
];
2525
}
26+
27+
public function getRouting()
28+
{
29+
return $this->hasOne(\app\models\Routing::class, ['d123_id' => 'id'])->inverseOf('d123');
30+
}
2631
}

tests/specs/relations_in_faker/app/models/base/Domain.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public function getAccount()
3838

3939
public function getRoutings()
4040
{
41-
return $this->hasMany(\app\models\Routing::class, ['domain_id' => 'id']);
41+
return $this->hasMany(\app\models\Routing::class, ['domain_id' => 'id'])->inverseOf('domain');
42+
}
43+
44+
public function getRouting()
45+
{
46+
return $this->hasOne(\app\models\Routing::class, ['domain_id' => 'id'])->inverseOf('domain');
4247
}
4348
}

tests/specs/relations_in_faker/app/models/base/Routing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace app\models\base;
44

55
/**
6-
* rounting specification
6+
* routing specification
77
*
88
* @property int $id
99
* @property int $domain_id domain

tests/specs/relations_in_faker/relations_in_faker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ components:
6464
nullable: false
6565

6666
Routing:
67-
description: rounting specification
67+
description: routing specification
6868
type: object
6969
required:
7070
- id

0 commit comments

Comments
 (0)