|
7 | 7 | use Zenstruck\Foundry\Test\Factories; |
8 | 8 | use Zenstruck\Foundry\Test\ResetDatabase; |
9 | 9 | use Zenstruck\Foundry\Tests\Fixtures\Entity\Category; |
| 10 | +use Zenstruck\Foundry\Tests\Fixtures\Factories\AddressFactory; |
10 | 11 | use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryFactory; |
11 | 12 | use Zenstruck\Foundry\Tests\Fixtures\Factories\CommentFactory; |
| 13 | +use Zenstruck\Foundry\Tests\Fixtures\Factories\ContactFactory; |
12 | 14 | use Zenstruck\Foundry\Tests\Fixtures\Factories\PostFactory; |
13 | 15 | use Zenstruck\Foundry\Tests\Fixtures\Factories\PostFactoryWithInvalidInitialize; |
14 | 16 | use Zenstruck\Foundry\Tests\Fixtures\Factories\PostFactoryWithNullInitialize; |
@@ -440,4 +442,30 @@ public function can_find_by(): void |
440 | 442 | $this->assertSame('name2', $categories[0]->getName()); |
441 | 443 | $this->assertSame('name2', $categories[1]->getName()); |
442 | 444 | } |
| 445 | + |
| 446 | + /** |
| 447 | + * @test |
| 448 | + */ |
| 449 | + public function embeddables_are_never_persisted(): void |
| 450 | + { |
| 451 | + $object1 = AddressFactory::createOne(); |
| 452 | + $object2 = AddressFactory::createOne(['value' => 'another address']); |
| 453 | + |
| 454 | + $this->assertSame('Some address', $object1->getValue()); |
| 455 | + $this->assertSame('another address', $object2->getValue()); |
| 456 | + } |
| 457 | + |
| 458 | + /** |
| 459 | + * @test |
| 460 | + */ |
| 461 | + public function factory_with_embeddable(): void |
| 462 | + { |
| 463 | + ContactFactory::repository()->assert()->empty(); |
| 464 | + |
| 465 | + $object = ContactFactory::createOne(); |
| 466 | + |
| 467 | + ContactFactory::repository()->assert()->count(1); |
| 468 | + $this->assertSame('Sally', $object->getName()); |
| 469 | + $this->assertSame('Some address', $object->getAddress()->getValue()); |
| 470 | + } |
443 | 471 | } |
0 commit comments