Skip to content

Commit

Permalink
Add test and update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jul 4, 2024
1 parent bc43cdf commit b3079ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 0 additions & 5 deletions docs/using-di.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ final class User extends ActiveRecord
{
$this->factory = $factory;
}

public function getMyService(): MyService
{
return $this->myService;
}
}
```

Expand Down
13 changes: 13 additions & 0 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,19 @@ public function testWithFactoryInstanceRelation(): void
$this->assertInstanceOf(CustomerWithFactory::class, $order->getCustomerWithFactoryInstance());
}

public function testWithFactoryRelationWithoutFactory(): void
{
$this->checkFixture($this->db(), 'order');

$factory = $this->createFactory();

$orderQuery = new ActiveQuery($factory->create(OrderWithFactory::class)->withFactory($factory));
$order = $orderQuery->findOne(2);

$this->assertInstanceOf(OrderWithFactory::class, $order);
$this->assertInstanceOf(Customer::class, $order->getCustomer());
}

public function testWithFactoryLazyRelation(): void
{
$this->checkFixture($this->db(), 'order');
Expand Down

0 comments on commit b3079ef

Please sign in to comment.