Skip to content

Commit

Permalink
fix: Ensure that nested factories can be created even if class alread…
Browse files Browse the repository at this point in the history
…y exists
  • Loading branch information
tomasnorre committed Jan 15, 2025
1 parent 316d3c7 commit 5eb1d51
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Integration/Maker/MakeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Zenstruck\Foundry\Maker\Factory\FactoryGenerator;
use Zenstruck\Foundry\Tests\Fixture\Document\GenericDocument;
use Zenstruck\Foundry\Tests\Fixture\Document\WithEmbeddableDocument;
use Zenstruck\Foundry\Tests\Fixture\Entity\Address;
use Zenstruck\Foundry\Tests\Fixture\Entity\Category;
use Zenstruck\Foundry\Tests\Fixture\Entity\Contact;
use Zenstruck\Foundry\Tests\Fixture\Entity\GenericEntity;
Expand Down Expand Up @@ -118,6 +119,22 @@ public function can_create_factory_in_test_dir(): void
$this->assertFileExists(self::tempFile('tests/Factory/CategoryFactory.php'));
}

/**
* @test
*/
public function can_create_factory_in_test_dir_with_nested_factory_already_created(): void
{
if (!\getenv('DATABASE_URL')) {
self::markTestSkipped('doctrine/orm not enabled.');
}

$tester = $this->makeFactoryCommandTester();
$tester->execute(['class' => Contact::class, '--test' => true]);
$tester->execute(['class' => Address::class, '--test' => true]);
$this->assertFileExists(self::tempFile('tests/Factory/ContactFactory.php'));
$this->assertFileExists(self::tempFile('tests/Factory/AddressFactory.php'));
}

/**
* @test
* @dataProvider scaToolProvider
Expand Down

0 comments on commit 5eb1d51

Please sign in to comment.