diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 79a7b9e69..d6b931622 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -173,11 +173,11 @@ jobs: - name: Test run: | - ./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php + ./phpunit --testsuite reset-database # We should be able to run the tests twice in order to check if the second run also starts from a fresh db # some bugs could be detected this way - ./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php + ./phpunit --testsuite reset-database shell: bash env: SYMFONY_REQUIRE: 8.0.* diff --git a/config/persistence.php b/config/persistence.php index d0f25d483..59ad64df9 100644 --- a/config/persistence.php +++ b/config/persistence.php @@ -40,15 +40,11 @@ 'command' => 'foundry:load-fixtures|foundry:load-stories|foundry:load-story', 'description' => 'Load stories which are marked with #[AsFixture] attribute.', ]) - ; - - if (\PHP_VERSION_ID >= 80400) { - $container->services()->set('.foundry.persistence.objects_tracker', PersistedObjectsTracker::class) + ->set('.foundry.persistence.objects_tracker', PersistedObjectsTracker::class) ->tag('kernel.reset', ['method' => 'refresh']) ->tag('kernel.event_listener', ['event' => TerminateEvent::class, 'method' => 'refresh']) ->tag('kernel.event_listener', ['event' => ConsoleTerminateEvent::class, 'method' => 'refresh']) ->tag('kernel.event_listener', ['event' => WorkerMessageHandledEvent::class, 'method' => 'refresh']) // @phpstan-ignore class.notFound ->tag('foundry.hook', ['class' => null, 'method' => 'afterPersistHook', 'event' => AfterPersist::class]) - ; - } + ; }; diff --git a/phpstan.neon b/phpstan.neon index 2e27d0d5b..73594e32e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -26,9 +26,6 @@ parameters: - identifier: missingType.iterableValue path: tests/ - # PHPStan does not understand PHP version checks - - message: '#Comparison operation "(<|>|<=|>=)" between int<80\d+, 80\d+> and 80\d+ is always (false|true).#' - # Hydrator and Factory are annotated @immutable - identifier: property.readOnlyByPhpDocDefaultValue paths: diff --git a/phpunit-deprecation-baseline.xml b/phpunit-deprecation-baseline.xml index af4528aea..be6f6a4b5 100644 --- a/phpunit-deprecation-baseline.xml +++ b/phpunit-deprecation-baseline.xml @@ -1,18 +1,7 @@ - - - - - - - - - - - diff --git a/skeleton/Factory.tpl.php b/skeleton/Factory.tpl.php index 0a87e7667..278e7eea5 100644 --- a/skeleton/Factory.tpl.php +++ b/skeleton/Factory.tpl.php @@ -22,7 +22,7 @@ public function __construct() { } -shouldAddOverrideAttributes()): ?> #[\Override] + #[\Override] public static function class(): string { return getObjectShortName(); ?>::class; @@ -33,7 +33,7 @@ public static function class(): string * * @todo add your default values here */ -shouldAddOverrideAttributes()): ?> #[\Override] + #[\Override] protected function defaults(): arrayshouldAddHints()): ?>|callable { return [ @@ -48,7 +48,7 @@ protected function defaults(): arrayshouldAddHints() shouldAddHints()): ?> /** * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization */ -shouldAddOverrideAttributes()): ?> #[\Override] + #[\Override] protected function initialize(): static { return $this diff --git a/src/Maker/Factory/MakeFactoryData.php b/src/Maker/Factory/MakeFactoryData.php index 4c74eaf0a..7fa569ec5 100644 --- a/src/Maker/Factory/MakeFactoryData.php +++ b/src/Maker/Factory/MakeFactoryData.php @@ -157,10 +157,6 @@ public function getDefaultProperties(): array public function addEnumDefaultProperty(string $propertyName, string $enumClass): void { - if (\PHP_VERSION_ID < 80100) { - throw new \LogicException('Cannot add enum for php version inferior than 8.1'); - } - if (!\enum_exists($enumClass)) { throw new \InvalidArgumentException("Enum of class \"{$enumClass}\" does not exist."); } @@ -179,14 +175,6 @@ public function shouldAddHints(): bool return $this->addHints; } - /** - * @phpstan-ignore return.tooWideBool - */ - public function shouldAddOverrideAttributes(): bool - { - return \PHP_VERSION_ID >= 80300; - } - private static function propertyInfo(): ReflectionExtractor { return self::$propertyInfo ??= new ReflectionExtractor(); diff --git a/src/Maker/Factory/ObjectDefaultPropertiesGuesser.php b/src/Maker/Factory/ObjectDefaultPropertiesGuesser.php index ba6a1378c..a24359bae 100644 --- a/src/Maker/Factory/ObjectDefaultPropertiesGuesser.php +++ b/src/Maker/Factory/ObjectDefaultPropertiesGuesser.php @@ -39,7 +39,7 @@ public function __invoke(SymfonyStyle $io, MakeFactoryData $makeFactoryData, Mak $value = \sprintf('null, // TODO add %svalue manually', $type ? "{$type} " : ''); - if (\PHP_VERSION_ID >= 80100 && \enum_exists($type)) { + if (\enum_exists($type)) { $makeFactoryData->addEnumDefaultProperty($property->getName(), $type); continue; diff --git a/tests/Fixture/DoctrineCascadeRelationship/ChangesEntityRelationshipCascadePersist.php b/tests/Fixture/DoctrineCascadeRelationship/ChangesEntityRelationshipCascadePersist.php index d9512862e..8f831e42b 100644 --- a/tests/Fixture/DoctrineCascadeRelationship/ChangesEntityRelationshipCascadePersist.php +++ b/tests/Fixture/DoctrineCascadeRelationship/ChangesEntityRelationshipCascadePersist.php @@ -14,12 +14,12 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\BeforeClass; use PHPUnit\Framework\Attributes\DataProvider; use Psr\Cache\CacheItemPoolInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Configuration; use Zenstruck\Foundry\Persistence\PersistenceManager; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE @@ -36,10 +36,16 @@ */ trait ChangesEntityRelationshipCascadePersist { - use RequiresORM; - private static string $methodName = ''; + #[BeforeClass] + public static function _requiresORM(): void + { + if (!\getenv('DATABASE_URL')) { + self::markTestSkipped('SQL database not available.'); + } + } + #[Before] public function setUpCascadePersistMetadata(): void { @@ -82,9 +88,7 @@ public static function provideCascadeRelationshipsCombinations(): iterable } if (!\getenv('DATABASE_URL') || !self::$methodName) { - // this test requires the ORM, but trait RequiresORM is analysed after data provider are called - // then we need to return at least one empty array to avoid an error - // in PHPUnit 12, we will be able to use #[RequiresEnvironmentVariable('DATABASE_URL')] to prevent this + // data providers are resolved before #[RequiresEnvironmentVariable] is checked yield []; // @phpstan-ignore generator.valueType return; diff --git a/tests/Integration/ArrayFactoryTest.php b/tests/Integration/ArrayFactoryTest.php index f47c1c00b..675938eb5 100644 --- a/tests/Integration/ArrayFactoryTest.php +++ b/tests/Integration/ArrayFactoryTest.php @@ -11,7 +11,6 @@ namespace Zenstruck\Foundry\Tests\Integration; -use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\LazyValue; @@ -22,11 +21,7 @@ */ final class ArrayFactoryTest extends KernelTestCase { - /** - * @test - */ #[Test] - #[IgnoreDeprecations] public function can_create_with_defaults(): void { $this->assertSame( @@ -40,9 +35,6 @@ public function can_create_with_defaults(): void ); } - /** - * @test - */ #[Test] public function can_create_with_overrides(): void { diff --git a/tests/Integration/Attribute/WithStory/ParentClassWithStoryAttributeTestCase.php b/tests/Integration/Attribute/WithStory/ParentClassWithStoryAttributeTestCase.php index a74ae59e0..12d470523 100644 --- a/tests/Integration/Attribute/WithStory/ParentClassWithStoryAttributeTestCase.php +++ b/tests/Integration/Attribute/WithStory/ParentClassWithStoryAttributeTestCase.php @@ -15,7 +15,6 @@ use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Attribute\WithStory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE @@ -24,5 +23,4 @@ #[ResetDatabase] abstract class ParentClassWithStoryAttributeTestCase extends KernelTestCase { - use RequiresORM; } diff --git a/tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php b/tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php index d2f29f8fd..51bdbb4a6 100644 --- a/tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php +++ b/tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php @@ -11,30 +11,23 @@ namespace Zenstruck\Foundry\Tests\Integration\Attribute\WithStory; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Attribute\WithStory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[WithStory(EntityStory::class)] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class WithStoryOnClassTest extends KernelTestCase { - use RequiresORM; - #[Test] public function can_use_story_in_attribute(): void { diff --git a/tests/Integration/Attribute/WithStory/WithStoryOnMethodTest.php b/tests/Integration/Attribute/WithStory/WithStoryOnMethodTest.php index 56e3cf6ae..0d0964ceb 100644 --- a/tests/Integration/Attribute/WithStory/WithStoryOnMethodTest.php +++ b/tests/Integration/Attribute/WithStory/WithStoryOnMethodTest.php @@ -11,30 +11,23 @@ namespace Zenstruck\Foundry\Tests\Integration\Attribute\WithStory; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Attribute\WithStory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; use Zenstruck\Foundry\Tests\Fixture\Stories\ServiceStory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class WithStoryOnMethodTest extends KernelTestCase { - use RequiresORM; - #[Test] #[WithStory(EntityStory::class)] public function can_use_story_in_attribute(): void diff --git a/tests/Integration/Attribute/WithStory/WithStoryOnParentClassTest.php b/tests/Integration/Attribute/WithStory/WithStoryOnParentClassTest.php index 5cdacbc38..2a81b7298 100644 --- a/tests/Integration/Attribute/WithStory/WithStoryOnParentClassTest.php +++ b/tests/Integration/Attribute/WithStory/WithStoryOnParentClassTest.php @@ -11,21 +11,17 @@ namespace Zenstruck\Foundry\Tests\Integration\Attribute\WithStory; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Zenstruck\Foundry\Attribute\WithStory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[WithStory(EntityPoolStory::class)] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class WithStoryOnParentClassTest extends ParentClassWithStoryAttributeTestCase { #[Test] diff --git a/tests/Integration/Command/LoadFixturesCommandTest.php b/tests/Integration/Command/LoadFixturesCommandTest.php index 5511f9e07..ada89849b 100644 --- a/tests/Integration/Command/LoadFixturesCommandTest.php +++ b/tests/Integration/Command/LoadFixturesCommandTest.php @@ -12,6 +12,7 @@ namespace Zenstruck\Foundry\Tests\Integration\Command; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -25,18 +26,13 @@ use Zenstruck\Foundry\Tests\Fixture\Stories\Fixtures\FixtureStory; use Zenstruck\Foundry\Tests\Fixture\Stories\Fixtures\FixtureStoryWithNameCollision; use Zenstruck\Foundry\Tests\Fixture\TestKernel; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\repository; #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class LoadFixturesCommandTest extends KernelTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function it_throws_if_no_story_marked_as_fixture(): void { @@ -46,9 +42,6 @@ public function it_throws_if_no_story_marked_as_fixture(): void $this->commandTester()->execute(['name' => 'foo']); } - /** - * @test - */ #[Test] public function it_throws_if_story_does_not_exist(): void { @@ -58,9 +51,6 @@ public function it_throws_if_story_does_not_exist(): void $this->commandTester(['environment' => 'stories_as_fixtures'])->execute(['name' => 'invalid-name', '--append' => true]); } - /** - * @test - */ #[Test] public function it_can_load_a_story(): void { @@ -70,9 +60,6 @@ public function it_can_load_a_story(): void GenericEntityFactory::assert()->count(1, ['prop1' => 'fixture-story']); } - /** - * @test - */ #[Test] public function it_can_load_a_story_with_verbose_mode(): void { @@ -85,9 +72,6 @@ public function it_can_load_a_story_with_verbose_mode(): void self::assertStringContainsString('loaded (name: fixture-story)', $commandTester->getDisplay()); } - /** - * @test - */ #[Test] public function it_throws_if_name_collision_between_two_stories_name(): void { @@ -103,9 +87,6 @@ public function it_throws_if_name_collision_between_two_stories_name(): void $this->commandTester(['environment' => 'story_fixture_with_name_collision'])->execute(['name' => 'fixture-story', '--append' => true]); } - /** - * @test - */ #[Test] public function it_throws_if_name_collision_between_story_name_and_group_name(): void { @@ -115,9 +96,6 @@ public function it_throws_if_name_collision_between_story_name_and_group_name(): $this->commandTester(['environment' => 'story_fixture_with_group_name_collision'])->execute(['name' => 'fixture-story', '--append' => true]); } - /** - * @test - */ #[Test] public function it_can_load_one_single_story_based_on_its_group_name(): void { @@ -127,9 +105,6 @@ public function it_can_load_one_single_story_based_on_its_group_name(): void GenericEntityFactory::assert()->count(1, ['prop1' => 'fixture-story']); } - /** - * @test - */ #[Test] public function it_can_load_multiple_stories_based_on_their_group_name(): void { @@ -140,10 +115,6 @@ public function it_can_load_multiple_stories_based_on_their_group_name(): void GenericEntityFactory::assert()->count(1, ['prop1' => 'fixture-story-for-group']); } - /** - * @test - * @dataProvider provideFixturesWhichLoadAnotherFixtureCases - */ #[Test] #[DataProvider('provideFixturesWhichLoadAnotherFixtureCases')] public function it_can_load_fixture_which_loads_another_fixture(string $name): void @@ -161,9 +132,6 @@ public static function provideFixturesWhichLoadAnotherFixtureCases(): iterable yield 'by group name' => ['fixture-using-another-fixture-group']; } - /** - * @test - */ #[Test] public function it_can_load_a_story_and_reset_database(): void { @@ -179,9 +147,6 @@ public function it_can_load_a_story_and_reset_database(): void GenericEntityFactory::assert()->count(1, ['prop1' => 'fixture-story']); } - /** - * @test - */ #[Test] public function user_can_refuse_to_reset_database(): void { @@ -194,9 +159,6 @@ public function user_can_refuse_to_reset_database(): void GenericEntityFactory::assert()->count(0); } - /** - * @test - */ #[Test] public function it_does_not_reset_database_if_append_option_is_used(): void { @@ -211,9 +173,6 @@ public function it_does_not_reset_database_if_append_option_is_used(): void GenericEntityFactory::assert()->count(6); } - /** - * @test - */ #[Test] public function if_no_name_provided_it_asks_for_story_to_load(): void { @@ -228,9 +187,6 @@ public function if_no_name_provided_it_asks_for_story_to_load(): void self::assertStringContainsString('Loading story with name "fixture-story"', $commandTester->getDisplay()); } - /** - * @test - */ #[Test] public function if_no_name_provided_it_asks_for_group_to_load(): void { @@ -246,9 +202,6 @@ public function if_no_name_provided_it_asks_for_group_to_load(): void self::assertStringContainsString('Loading stories group "multiple-fixtures-in-group"', $commandTester->getDisplay()); } - /** - * @test - */ #[Test] public function if_no_name_provided_and_on_one_story_fixture_it_loads_it_automatically(): void { @@ -261,9 +214,6 @@ public function if_no_name_provided_and_on_one_story_fixture_it_loads_it_automat self::assertStringContainsString('Loading story with name "fixture-story"', $commandTester->getDisplay()); } - /** - * @test - */ #[Test] public function it_does_not_load_global_state(): void { diff --git a/tests/Integration/DataProvider/DataProviderForServiceFactoryInKernelTestCaseTest.php b/tests/Integration/DataProvider/DataProviderForServiceFactoryInKernelTestCaseTest.php index 4a9307ea5..6c4e476ee 100644 --- a/tests/Integration/DataProvider/DataProviderForServiceFactoryInKernelTestCaseTest.php +++ b/tests/Integration/DataProvider/DataProviderForServiceFactoryInKernelTestCaseTest.php @@ -12,12 +12,9 @@ namespace Zenstruck\Foundry\Tests\Integration\DataProvider; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Configuration; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Factories\Object1Factory; use Zenstruck\Foundry\Tests\Fixture\Object1; @@ -25,10 +22,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] -#[RequiresPhpunitExtension(FoundryExtension::class)] final class DataProviderForServiceFactoryInKernelTestCaseTest extends KernelTestCase { #[Test] diff --git a/tests/Integration/DataProvider/DataProviderInUnitTest.php b/tests/Integration/DataProvider/DataProviderInUnitTest.php index d9b091e19..a79ef0d8d 100644 --- a/tests/Integration/DataProvider/DataProviderInUnitTest.php +++ b/tests/Integration/DataProvider/DataProviderInUnitTest.php @@ -12,10 +12,8 @@ namespace Zenstruck\Foundry\Tests\Integration\DataProvider; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\GenericEntity; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Object1Factory; @@ -28,7 +26,6 @@ /** * @author Nicolas PHILIPPE */ -#[RequiresPhpunitExtension(FoundryExtension::class)] final class DataProviderInUnitTest extends TestCase { #[Test] diff --git a/tests/Integration/DataProvider/DataProviderWithInMemoryTest.php b/tests/Integration/DataProvider/DataProviderWithInMemoryTest.php index e00ac8b74..a7b6d3070 100644 --- a/tests/Integration/DataProvider/DataProviderWithInMemoryTest.php +++ b/tests/Integration/DataProvider/DataProviderWithInMemoryTest.php @@ -13,27 +13,23 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\InMemory\AsInMemoryTest; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\Contact; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; use Zenstruck\Foundry\Tests\Fixture\InMemory\InMemoryContactRepository; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE */ -#[RequiresPhpunitExtension(FoundryExtension::class)] +#[RequiresEnvironmentVariable('DATABASE_URL')] // needed to use the entity manager #[ResetDatabase] final class DataProviderWithInMemoryTest extends KernelTestCase { - use RequiresORM; // needed to use the entity manager - private InMemoryContactRepository $contactRepository; private EntityManagerInterface $entityManager; diff --git a/tests/Integration/DataProvider/DataProviderWithPersistentDocumentFactoryTest.php b/tests/Integration/DataProvider/DataProviderWithPersistentDocumentFactoryTest.php index 33ad958cd..26ec3f2b7 100644 --- a/tests/Integration/DataProvider/DataProviderWithPersistentDocumentFactoryTest.php +++ b/tests/Integration/DataProvider/DataProviderWithPersistentDocumentFactoryTest.php @@ -12,9 +12,7 @@ namespace Zenstruck\Foundry\Tests\Integration\DataProvider; use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Document\DocumentWithReadonly; use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericDocumentFactory; use Zenstruck\Foundry\Tests\Fixture\Model\Embeddable; @@ -24,7 +22,6 @@ /** * @author Nicolas PHILIPPE */ -#[RequiresPhpunitExtension(FoundryExtension::class)] #[RequiresEnvironmentVariable('MONGO_URL')] final class DataProviderWithPersistentDocumentFactoryTest extends DataProviderWithPersistentFactoryTestCase { diff --git a/tests/Integration/DataProvider/DataProviderWithPersistentEntityFactoryTest.php b/tests/Integration/DataProvider/DataProviderWithPersistentEntityFactoryTest.php index a36486434..a70b3f515 100644 --- a/tests/Integration/DataProvider/DataProviderWithPersistentEntityFactoryTest.php +++ b/tests/Integration/DataProvider/DataProviderWithPersistentEntityFactoryTest.php @@ -12,9 +12,7 @@ namespace Zenstruck\Foundry\Tests\Integration\DataProvider; use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\EntityWithReadonly\EntityWithReadonly; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Model\Embeddable; @@ -24,7 +22,6 @@ /** * @author Nicolas PHILIPPE */ -#[RequiresPhpunitExtension(FoundryExtension::class)] #[RequiresEnvironmentVariable('DATABASE_URL')] final class DataProviderWithPersistentEntityFactoryTest extends DataProviderWithPersistentFactoryTestCase { diff --git a/tests/Integration/EventsTest.php b/tests/Integration/EventsTest.php index 113888065..3cc3b7719 100644 --- a/tests/Integration/EventsTest.php +++ b/tests/Integration/EventsTest.php @@ -11,19 +11,16 @@ namespace Zenstruck\Foundry\Tests\Integration; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Tests\Fixture\Events\FactoryWithEventListeners; #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class EventsTest extends KernelTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function it_can_call_hooks(): void { diff --git a/tests/Integration/Faker/FakerCustomServiceKernelTest.php b/tests/Integration/Faker/FakerCustomServiceKernelTest.php index 6268e0625..7aa685ef0 100644 --- a/tests/Integration/Faker/FakerCustomServiceKernelTest.php +++ b/tests/Integration/Faker/FakerCustomServiceKernelTest.php @@ -11,7 +11,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpKernel\KernelInterface; @@ -22,9 +21,7 @@ /** * @author Silas Joisten - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] #[ResetDatabase] final class FakerCustomServiceKernelTest extends KernelTestCase { diff --git a/tests/Integration/Faker/FakerSeedAutomaticallySetKernelTest.php b/tests/Integration/Faker/FakerSeedAutomaticallySetKernelTest.php index 17d745eae..c9edfa495 100644 --- a/tests/Integration/Faker/FakerSeedAutomaticallySetKernelTest.php +++ b/tests/Integration/Faker/FakerSeedAutomaticallySetKernelTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; @@ -22,9 +21,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] #[ResetDatabase] final class FakerSeedAutomaticallySetKernelTest extends KernelTestCase { diff --git a/tests/Integration/Faker/FakerSeedAutomaticallySetUnitTest.php b/tests/Integration/Faker/FakerSeedAutomaticallySetUnitTest.php index 1c39365f1..1660edbe3 100644 --- a/tests/Integration/Faker/FakerSeedAutomaticallySetUnitTest.php +++ b/tests/Integration/Faker/FakerSeedAutomaticallySetUnitTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Zenstruck\Foundry\FakerAdapter; @@ -21,9 +20,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] final class FakerSeedAutomaticallySetUnitTest extends TestCase { use ResetFakerTestTrait; diff --git a/tests/Integration/Faker/FakerSeedDoNotConflictWithDataProviderTest.php b/tests/Integration/Faker/FakerSeedDoNotConflictWithDataProviderTest.php index 3a6ff5847..f80a74a6d 100644 --- a/tests/Integration/Faker/FakerSeedDoNotConflictWithDataProviderTest.php +++ b/tests/Integration/Faker/FakerSeedDoNotConflictWithDataProviderTest.php @@ -13,14 +13,10 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; -use PHPUnit\Framework\Attributes\RequiresPhp; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\FakerAdapter; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\WithUniqueColumn; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\WithUniqueColumn\WithUniqueColumnFactory; @@ -28,11 +24,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=12.0 */ -#[RequiresPhp('^8.4')] -#[RequiresPhpunit('>=12.0')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[RequiresEnvironmentVariable('DATABASE_URL')] #[ResetDatabase] final class FakerSeedDoNotConflictWithDataProviderTest extends KernelTestCase diff --git a/tests/Integration/Faker/FakerSeedIsNotResetDuringRunKernelTest.php b/tests/Integration/Faker/FakerSeedIsNotResetDuringRunKernelTest.php index 9135e92e6..cc4a6664b 100644 --- a/tests/Integration/Faker/FakerSeedIsNotResetDuringRunKernelTest.php +++ b/tests/Integration/Faker/FakerSeedIsNotResetDuringRunKernelTest.php @@ -11,23 +11,17 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; -use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\FakerAdapter; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\WithUniqueColumn\WithUniqueColumnFactory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; -/** - * @requires PHPUnit >=11.0 - */ -#[RequiresPhpunit('>=11.0')] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class FakerSeedIsNotResetDuringRunKernelTest extends WebTestCase { - use RequiresORM; - #[Test] public function faker_seed_is_not_reset_with_kernel_shutdown(): void { diff --git a/tests/Integration/Faker/FakerSeedSetFromEnvVarKernelTest.php b/tests/Integration/Faker/FakerSeedSetFromEnvVarKernelTest.php index 62d5a4b91..199ef80c3 100644 --- a/tests/Integration/Faker/FakerSeedSetFromEnvVarKernelTest.php +++ b/tests/Integration/Faker/FakerSeedSetFromEnvVarKernelTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpKernel\KernelInterface; @@ -23,9 +22,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] #[ResetDatabase] final class FakerSeedSetFromEnvVarKernelTest extends KernelTestCase { diff --git a/tests/Integration/Faker/FakerSeedSetFromEnvVarUnitTest.php b/tests/Integration/Faker/FakerSeedSetFromEnvVarUnitTest.php index 4dd8368b6..553d5fe47 100644 --- a/tests/Integration/Faker/FakerSeedSetFromEnvVarUnitTest.php +++ b/tests/Integration/Faker/FakerSeedSetFromEnvVarUnitTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Zenstruck\Foundry\FakerAdapter; @@ -21,9 +20,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=12.0 */ -#[RequiresPhpunit('>=12.0')] final class FakerSeedSetFromEnvVarUnitTest extends TestCase { #[Test] diff --git a/tests/Integration/Faker/FakerSeedShouldNotChangeIfSeedIsNotManagedByFoundryTest.php b/tests/Integration/Faker/FakerSeedShouldNotChangeIfSeedIsNotManagedByFoundryTest.php index 024cf4969..d0fb06ff6 100644 --- a/tests/Integration/Faker/FakerSeedShouldNotChangeIfSeedIsNotManagedByFoundryTest.php +++ b/tests/Integration/Faker/FakerSeedShouldNotChangeIfSeedIsNotManagedByFoundryTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\Faker; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\WithEnvironmentVariable; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -24,9 +23,7 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=12.0 */ -#[RequiresPhpunit('>=12.0')] #[ResetDatabase] final class FakerSeedShouldNotChangeIfSeedIsNotManagedByFoundryTest extends KernelTestCase { diff --git a/tests/Integration/InMemory/DoctrineInMemoryDecoratorTest.php b/tests/Integration/InMemory/DoctrineInMemoryDecoratorTest.php index 51f871c9d..6734bc475 100644 --- a/tests/Integration/InMemory/DoctrineInMemoryDecoratorTest.php +++ b/tests/Integration/InMemory/DoctrineInMemoryDecoratorTest.php @@ -12,12 +12,9 @@ namespace Zenstruck\Foundry\Tests\Integration\InMemory; use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\InMemory\AsInMemoryTest; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\WithEmbeddableEntity; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Category\CategoryFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; @@ -30,17 +27,11 @@ /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[RequiresEnvironmentVariable('DATABASE_URL')] #[AsInMemoryTest] final class DoctrineInMemoryDecoratorTest extends KernelTestCase { - /** - * @test - */ #[Test] public function it_can_find_by_one_param(): void { @@ -51,9 +42,6 @@ public function it_can_find_by_one_param(): void self::assertSame($expected, $found); } - /** - * @test - */ #[Test] public function it_can_find_by_two_params(): void { @@ -64,9 +52,6 @@ public function it_can_find_by_two_params(): void self::assertSame($expected, $found); } - /** - * @test - */ #[Test] public function it_can_limit_find_by_results(): void { @@ -80,9 +65,6 @@ public function it_can_limit_find_by_results(): void } } - /** - * @test - */ #[Test] public function it_can_order_find_by_results(): void { @@ -97,9 +79,6 @@ public function it_can_order_find_by_results(): void self::assertSame($sorted, $integers); } - /** - * @test - */ #[Test] public function it_can_order_desc_find_by_results(): void { @@ -113,9 +92,6 @@ public function it_can_order_desc_find_by_results(): void self::assertSame($sorted, $integers); } - /** - * @test - */ #[Test] public function it_can_use_offset(): void { @@ -128,9 +104,6 @@ public function it_can_use_offset(): void self::assertSame([2, 3, 4], $integers); } - /** - * @test - */ #[Test] public function it_can_use_limit_and_offset(): void { @@ -143,9 +116,6 @@ public function it_can_use_limit_and_offset(): void self::assertSame([2, 3], $integers); } - /** - * @test - */ #[Test] public function it_can_find_one_by(): void { @@ -156,9 +126,6 @@ public function it_can_find_one_by(): void self::assertSame($expected, $found); } - /** - * @test - */ #[Test] public function it_can_find_by_entity(): void { @@ -171,9 +138,6 @@ public function it_can_find_by_entity(): void self::assertSame($contacts, $contactsFound); } - /** - * @test - */ #[Test] public function it_can_find_by_embeddable(): void { diff --git a/tests/Integration/InMemory/InMemoryAttributeOnMethodTest.php b/tests/Integration/InMemory/InMemoryAttributeOnMethodTest.php index 9ad147617..717fdc33d 100644 --- a/tests/Integration/InMemory/InMemoryAttributeOnMethodTest.php +++ b/tests/Integration/InMemory/InMemoryAttributeOnMethodTest.php @@ -12,30 +12,23 @@ namespace Zenstruck\Foundry\Tests\Integration\InMemory; use Doctrine\ORM\EntityManagerInterface; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\InMemory\AsInMemoryTest; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\Address; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Address\AddressFactory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\delete; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class InMemoryAttributeOnMethodTest extends KernelTestCase { - use RequiresORM; - private EntityManagerInterface $entityManager; protected function setUp(): void @@ -43,9 +36,6 @@ protected function setUp(): void $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); // @phpstan-ignore assign.propertyType } - /** - * @test - */ #[Test] #[AsInMemoryTest] public function create_one_does_not_persist_in_database(): void @@ -59,9 +49,6 @@ public function create_one_does_not_persist_in_database(): void self::assertNull($address->id); } - /** - * @test - */ #[Test] public function not_in_memory_test(): void { diff --git a/tests/Integration/InMemory/InMemoryTest.php b/tests/Integration/InMemory/InMemoryTest.php index 2c535063c..392fc0b4b 100644 --- a/tests/Integration/InMemory/InMemoryTest.php +++ b/tests/Integration/InMemory/InMemoryTest.php @@ -12,14 +12,12 @@ namespace Zenstruck\Foundry\Tests\Integration\InMemory; use Doctrine\ORM\EntityManagerInterface; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Attribute\WithStory; use Zenstruck\Foundry\InMemory\AsInMemoryTest; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\Address; use Zenstruck\Foundry\Tests\Fixture\Entity\Category; use Zenstruck\Foundry\Tests\Fixture\Entity\Contact; @@ -31,20 +29,15 @@ use Zenstruck\Foundry\Tests\Fixture\InMemory\InMemoryAddressRepository; use Zenstruck\Foundry\Tests\Fixture\InMemory\InMemoryContactRepository; use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[AsInMemoryTest] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class InMemoryTest extends KernelTestCase { - use RequiresORM; - private InMemoryAddressRepository $addressRepository; private InMemoryContactRepository $contactRepository; @@ -58,9 +51,6 @@ protected function setUp(): void $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); // @phpstan-ignore assign.propertyType } - /** - * @test - */ #[Test] public function create_one_does_not_persist_in_database(): void { @@ -75,9 +65,6 @@ public function create_one_does_not_persist_in_database(): void self::assertCount(1, AddressFactory::repository()); } - /** - * @test - */ #[Test] public function create_many_does_not_persist_in_database(): void { @@ -94,9 +81,6 @@ public function create_many_does_not_persist_in_database(): void self::assertCount(2, AddressFactory::repository()); } - /** - * @test - */ #[Test] public function object_should_be_accessible_from_in_memory_repository(): void { @@ -107,9 +91,6 @@ public function object_should_be_accessible_from_in_memory_repository(): void self::assertCount(1, AddressFactory::repository()); } - /** - * @test - */ #[Test] public function nested_objects_should_be_accessible_from_their_respective_repository(): void { @@ -125,9 +106,6 @@ public function nested_objects_should_be_accessible_from_their_respective_reposi self::assertCount(1, AddressFactory::repository()); } - /** - * @test - */ #[Test] public function can_use_generic_repository(): void { @@ -143,9 +121,6 @@ public function can_use_generic_repository(): void self::assertCount(1, CategoryFactory::repository()); } - /** - * @test - */ #[Test] public function one_to_many(): void { @@ -160,9 +135,6 @@ public function one_to_many(): void } } - /** - * @test - */ #[Test] public function inversed_one_to_one(): void { diff --git a/tests/Integration/InMemory/InMemoryUsingSetUpTest.php b/tests/Integration/InMemory/InMemoryUsingSetUpTest.php index 655f70d58..d71a6ddda 100644 --- a/tests/Integration/InMemory/InMemoryUsingSetUpTest.php +++ b/tests/Integration/InMemory/InMemoryUsingSetUpTest.php @@ -11,30 +11,23 @@ namespace Zenstruck\Foundry\Tests\Integration\InMemory; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\InMemory\AsInMemoryTest; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Entity\Contact; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; use Zenstruck\Foundry\Tests\Fixture\InMemory\InMemoryContactRepository; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] -#[RequiresPhpunitExtension(FoundryExtension::class)] #[AsInMemoryTest] #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class InMemoryUsingSetUpTest extends KernelTestCase { - use RequiresORM; - private InMemoryContactRepository $contactRepository; private Contact $contact; @@ -48,9 +41,6 @@ protected function setUp(): void self::assertCount(1, ContactFactory::repository()); } - /** - * @test - */ #[Test] public function can_access_objects_created_in_set_up_method(): void { diff --git a/tests/Integration/Maker/MakeFactoryTest.php b/tests/Integration/Maker/MakeFactoryTest.php index 89caf29cf..47e0c7e3c 100644 --- a/tests/Integration/Maker/MakeFactoryTest.php +++ b/tests/Integration/Maker/MakeFactoryTest.php @@ -14,7 +14,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; -use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException; @@ -32,11 +31,8 @@ /** * @author Kevin Bond - * @group maker - * @requires PHP >=8.4 */ #[Group('maker')] -#[RequiresPhp('>=8.4')] final class MakeFactoryTest extends MakerTestCase { protected function setUp(): void @@ -46,9 +42,6 @@ protected function setUp(): void parent::setUp(); } - /** - * @test - */ #[Test] public function can_create_factory(): void { @@ -67,9 +60,6 @@ public function can_create_factory(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/CategoryFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_with_uid(): void { @@ -88,9 +78,6 @@ public function can_create_factory_with_uid(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/WithUidColumnFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_interactively(): void { @@ -116,9 +103,6 @@ public function can_create_factory_interactively(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/ContactFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_in_test_dir(): void { @@ -133,9 +117,6 @@ public function can_create_factory_in_test_dir(): void $this->assertFileExists(self::tempFile('tests/Factory/CategoryFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_for_entity_with_repository(): void { @@ -150,9 +131,6 @@ public function can_create_factory_for_entity_with_repository(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/GenericEntityFactory.php')); } - /** - * @test - */ #[Test] public function invalid_entity_throws_exception(): void { @@ -170,9 +148,6 @@ public function invalid_entity_throws_exception(): void $this->fail('Exception not thrown.'); } - /** - * @test - */ #[Test] public function can_create_factory_for_not_persisted_class(): void { @@ -183,9 +158,6 @@ public function can_create_factory_for_not_persisted_class(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/Object1Factory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_without_hints(): void { @@ -196,9 +168,6 @@ public function can_create_factory_without_hints(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/Object1Factory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_for_not_persisted_class_interactively(): void { @@ -215,9 +184,6 @@ public function can_create_factory_for_not_persisted_class_interactively(): void $this->assertFileExists(self::tempFile('src/Factory/Object1Factory.php')); } - /** - * @test - */ #[Test] public function can_customize_namespace(): void { @@ -235,9 +201,6 @@ public function can_customize_namespace(): void $this->assertStringContainsString('namespace App\\My\\Namespace;', \file_get_contents($expectedFile) ?: ''); } - /** - * @test - */ #[Test] public function can_customize_namespace_with_test_flag(): void { @@ -255,9 +218,6 @@ public function can_customize_namespace_with_test_flag(): void $this->assertStringContainsString('namespace App\\Tests\\My\\Namespace;', \file_get_contents($expectedFile) ?: ''); } - /** - * @test - */ #[Test] public function can_customize_namespace_with_root_namespace_prefix(): void { @@ -275,9 +235,6 @@ public function can_customize_namespace_with_root_namespace_prefix(): void $this->assertStringContainsString('namespace App\\My\\Namespace;', \file_get_contents($expectedFile) ?: ''); } - /** - * @test - */ #[Test] public function can_customize_namespace_with_test_flag_with_root_namespace_prefix(): void { @@ -295,10 +252,6 @@ public function can_customize_namespace_with_test_flag_with_root_namespace_prefi $this->assertStringContainsString('namespace App\\Tests\\My\\Namespace;', \file_get_contents($expectedFile) ?: ''); } - /** - * @test - * @dataProvider documentProvider - */ #[Test] #[DataProvider('documentProvider')] public function can_create_factory_for_odm(string $class, string $file): void @@ -324,9 +277,6 @@ public static function documentProvider(): iterable yield 'embedded document' => [WithEmbeddableDocument::class, 'WithEmbeddableDocumentFactory']; } - /** - * @test - */ #[Test] public function can_create_all_factories_for_doctrine_objects(): void { @@ -357,9 +307,6 @@ public function can_create_all_factories_for_doctrine_objects(): void } } - /** - * @test - */ #[Test] public function can_create_factory_with_auto_activated_not_persisted_option(): void { @@ -377,9 +324,6 @@ public function can_create_factory_with_auto_activated_not_persisted_option(): v $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/GenericEntityFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_with_all_fields(): void { @@ -418,9 +362,6 @@ public function can_create_factory_with_embeddable_odm(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/WithEmbeddableDocumentFactory.php')); } - /** - * @test - */ #[Test] public function can_create_factory_with_default_enum(): void { @@ -431,9 +372,6 @@ public function can_create_factory_with_default_enum(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/ObjectWithEnumFactory.php')); } - /** - * @test - */ #[Test] public function does_not_initialize_non_settable(): void { @@ -444,9 +382,6 @@ public function does_not_initialize_non_settable(): void $this->assertFileFromMakerSameAsExpectedFile(self::tempFile('src/Factory/ObjectWithNonWriteableFactory.php')); } - /** - * @test - */ #[Test] public function does_force_initialization_of_non_settable_with_always_force(): void { diff --git a/tests/Integration/Maker/MakeStoryTest.php b/tests/Integration/Maker/MakeStoryTest.php index 9f30d9f1b..34e7b0319 100644 --- a/tests/Integration/Maker/MakeStoryTest.php +++ b/tests/Integration/Maker/MakeStoryTest.php @@ -19,15 +19,10 @@ /** * @author Kevin Bond - * @group maker */ #[Group('maker')] final class MakeStoryTest extends MakerTestCase { - /** - * @test - * @dataProvider storyNameProvider - */ #[Test] #[DataProvider('storyNameProvider')] public function can_create_story(string $name): void @@ -68,10 +63,6 @@ public function build(): void ); } - /** - * @test - * @dataProvider storyNameProvider - */ #[Test] #[DataProvider('storyNameProvider')] public function can_create_story_interactively(string $name): void @@ -116,10 +107,6 @@ public function build(): void ); } - /** - * @test - * @dataProvider storyNameProvider - */ #[Test] #[DataProvider('storyNameProvider')] public function can_create_story_in_test_dir(string $name): void @@ -160,10 +147,6 @@ public function build(): void ); } - /** - * @test - * @dataProvider storyNameProvider - */ #[Test] #[DataProvider('storyNameProvider')] public function can_create_story_in_test_dir_interactively(string $name): void @@ -218,8 +201,6 @@ public static function storyNameProvider(): iterable } /** - * @test - * @dataProvider namespaceProvider * @param array $commandOptions */ #[Test] diff --git a/tests/Integration/Maker/MakerTestCase.php b/tests/Integration/Maker/MakerTestCase.php index b25e46dd6..6a7201c20 100644 --- a/tests/Integration/Maker/MakerTestCase.php +++ b/tests/Integration/Maker/MakerTestCase.php @@ -19,14 +19,10 @@ /** * @author Kevin Bond - * @group maker */ #[Group('maker')] abstract class MakerTestCase extends KernelTestCase { - /** - * @before - */ #[Before] public static function cleanupTempDir(): void { diff --git a/tests/Integration/Mongo/EmbeddableDocumentFactoryTest.php b/tests/Integration/Mongo/EmbeddableDocumentFactoryTest.php index f019c33e9..56011f96c 100644 --- a/tests/Integration/Mongo/EmbeddableDocumentFactoryTest.php +++ b/tests/Integration/Mongo/EmbeddableDocumentFactoryTest.php @@ -11,12 +11,12 @@ namespace Zenstruck\Foundry\Tests\Integration\Mongo; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; use Zenstruck\Foundry\Tests\Fixture\Document\WithEmbeddableDocument; use Zenstruck\Foundry\Tests\Fixture\Model\Embeddable; use Zenstruck\Foundry\Tests\Integration\Persistence\EmbeddableFactoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresMongo; use function Zenstruck\Foundry\factory; use function Zenstruck\Foundry\Persistence\persist; @@ -26,13 +26,9 @@ /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('MONGO_URL')] final class EmbeddableDocumentFactoryTest extends EmbeddableFactoryTestCase { - use RequiresMongo; - - /** - * @test - */ #[Test] public function embed_many(): void { diff --git a/tests/Integration/Mongo/GenericDocumentFactoryTest.php b/tests/Integration/Mongo/GenericDocumentFactoryTest.php index df7be982f..3365fd807 100644 --- a/tests/Integration/Mongo/GenericDocumentFactoryTest.php +++ b/tests/Integration/Mongo/GenericDocumentFactoryTest.php @@ -11,17 +11,16 @@ namespace Zenstruck\Foundry\Tests\Integration\Mongo; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericDocumentFactory; use Zenstruck\Foundry\Tests\Integration\Persistence\GenericFactoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresMongo; /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('MONGO_URL')] final class GenericDocumentFactoryTest extends GenericFactoryTestCase { - use RequiresMongo; - protected static function factory(): GenericDocumentFactory { return GenericDocumentFactory::new(); diff --git a/tests/Integration/Mongo/GenericDocumentRepositoryDecoratorTest.php b/tests/Integration/Mongo/GenericDocumentRepositoryDecoratorTest.php index 781994d7a..5d7a01c01 100644 --- a/tests/Integration/Mongo/GenericDocumentRepositoryDecoratorTest.php +++ b/tests/Integration/Mongo/GenericDocumentRepositoryDecoratorTest.php @@ -11,15 +11,14 @@ namespace Zenstruck\Foundry\Tests\Integration\Mongo; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericDocumentFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\GenericModelFactory; use Zenstruck\Foundry\Tests\Integration\Persistence\GenericRepositoryDecoratorTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresMongo; +#[RequiresEnvironmentVariable('MONGO_URL')] final class GenericDocumentRepositoryDecoratorTest extends GenericRepositoryDecoratorTestCase { - use RequiresMongo; - protected function factory(): GenericModelFactory { return GenericDocumentFactory::new(); diff --git a/tests/Integration/Mongo/MongoStoryTest.php b/tests/Integration/Mongo/MongoStoryTest.php index 432317b08..e99c5efa0 100644 --- a/tests/Integration/Mongo/MongoStoryTest.php +++ b/tests/Integration/Mongo/MongoStoryTest.php @@ -11,19 +11,18 @@ namespace Zenstruck\Foundry\Tests\Integration\Mongo; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericDocumentFactory; use Zenstruck\Foundry\Tests\Fixture\Stories\DocumentPoolStory; use Zenstruck\Foundry\Tests\Fixture\Stories\DocumentStory; use Zenstruck\Foundry\Tests\Integration\Persistence\StoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresMongo; /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('MONGO_URL')] final class MongoStoryTest extends StoryTestCase { - use RequiresMongo; - protected static function storyClass(): string { return DocumentStory::class; diff --git a/tests/Integration/Mongo/PersistenceManagerTest.php b/tests/Integration/Mongo/PersistenceManagerTest.php index bd984d200..23724759c 100644 --- a/tests/Integration/Mongo/PersistenceManagerTest.php +++ b/tests/Integration/Mongo/PersistenceManagerTest.php @@ -13,14 +13,13 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Tests\Fixture\Document\DocumentWithUid; use Zenstruck\Foundry\Tests\Integration\Persistence\PersistenceManagerTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresMongo; +#[RequiresEnvironmentVariable('MONGO_URL')] final class PersistenceManagerTest extends PersistenceManagerTestCase { - use RequiresMongo; - protected static function createObject(): object { return new DocumentWithUid(); diff --git a/tests/Integration/ORM/EdgeCasesRelationshipTest.php b/tests/Integration/ORM/EdgeCasesRelationshipTest.php index 46a5512c1..82dcdbb78 100644 --- a/tests/Integration/ORM/EdgeCasesRelationshipTest.php +++ b/tests/Integration/ORM/EdgeCasesRelationshipTest.php @@ -14,7 +14,7 @@ use Doctrine\Common\Collections\Collection; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings; -use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; @@ -34,7 +34,6 @@ use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\OneToManyWithUnionType; use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\RichDomainMandatoryRelationship; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\EdgeCases\MultipleMandatoryRelationshipToSameEntity; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\persistent_factory; use function Zenstruck\Foundry\Persistence\refresh; @@ -42,20 +41,19 @@ /** * @author Nicolas PHILIPPE */ +#[RequiresEnvironmentVariable('DATABASE_URL')] #[ResetDatabase] final class EdgeCasesRelationshipTest extends KernelTestCase { - use ChangesEntityRelationshipCascadePersist, RequiresORM; + use ChangesEntityRelationshipCascadePersist; // Because we're handling the provided data manually in a #[Before] method, // PHPUnit triggers a warning, which we ignore with #[IgnorePhpunitWarnings] public const DATA_PROVIDER_WARNING_REGEX = 'Data set "(.)*" provided by Zenstruck(.)*::provideCascadeRelationshipsCombinations has more arguments \(\d\) than the test method accepts \(0\)'; - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(RichDomainMandatoryRelationship\OwningSide::class, ['main'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inversed_relationship_mandatory(): void { @@ -71,11 +69,9 @@ public function inversed_relationship_mandatory(): void $inversedSideEntityFactory::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithNonNullableOwning\OwningSide::class, ['inverseSide'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inverse_one_to_one_with_non_nullable_inverse_side(): void { @@ -90,11 +86,9 @@ public function inverse_one_to_one_with_non_nullable_inverse_side(): void self::assertSame($inverseSide, $inverseSide->getOwningSide()->inverseSide); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithSetter\OwningSide::class, ['inverseSide'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inverse_one_to_one_with_both_nullable(): void { @@ -109,12 +103,10 @@ public function inverse_one_to_one_with_both_nullable(): void self::assertSame($inverseSide, $inverseSide->getOwningSide()?->inverseSide); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithOneToMany\OwningSide::class, ['inverseSide'])] #[UsingRelationships(InversedOneToOneWithOneToMany\Item::class, ['owningSide'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inverse_one_to_one_with_one_to_many(): void { @@ -138,7 +130,6 @@ public function inverse_one_to_one_with_one_to_many(): void self::assertCount(2, $inverseSide->getOwningSide()->getItems()); } - /** @test */ #[Test] public function many_to_many_to_self_referencing_inverse_side(): void { @@ -151,11 +142,9 @@ public function many_to_many_to_self_referencing_inverse_side(): void $inverseSideFactory::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(IndexedOneToMany\ParentEntity::class, ['items'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function indexed_one_to_many(): void { @@ -174,11 +163,9 @@ public function indexed_one_to_many(): void self::assertNotNull($parent->getItems()->get('en')); // @phpstan-ignore argument.type } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithManyToOne\InverseSide::class, ['owningSide', 'item'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inversed_one_to_one_can_be_used_after_other_relationship(): void { @@ -203,11 +190,9 @@ public function inversed_one_to_one_can_be_used_after_other_relationship(): void self::assertNotNull($inverseSide->item); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithoutAutoGeneratedId\OwningSide::class, ['inverseSide'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function inverse_one_to_one_with_custom_id(): void { @@ -222,11 +207,9 @@ public function inverse_one_to_one_with_custom_id(): void self::assertSame($inverseSide, $inverseSide->owningSide->inverseSide); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(OneToManyWithUnionType\OwningSideEntity::class, ['item'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function after_instantiate_flushing_using_current_object_in_relationship_one_to_one(): void { @@ -246,7 +229,6 @@ public function after_instantiate_flushing_using_current_object_in_relationship_ self::assertInstanceOf(Collection::class, $object->collection); } - /** @test */ #[Test] public function inverse_one_to_one_without_nullable_throws(): void { @@ -263,7 +245,6 @@ public function inverse_one_to_one_without_nullable_throws(): void ); } - /** @test */ #[Test] public function inverse_one_to_one_without_types_throws(): void { @@ -280,11 +261,9 @@ public function inverse_one_to_one_without_types_throws(): void ); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(InversedOneToOneWithNonNullableOwning\OwningSide::class, ['inverseSide'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(self::DATA_PROVIDER_WARNING_REGEX)] public function after_instantiate_flushing_using_current_object_in_relationship_inverse_one_to_one(): void { @@ -306,9 +285,6 @@ static function(InversedOneToOneWithNonNullableOwning\OwningSide $o) use ($inver self::assertSame($owningSide, $owningSide->inverseSide->getOwningSide()); } - /** - * @test - */ #[Test] public function it_can_find_and_object_with_ulid_as_id(): void { @@ -320,9 +296,6 @@ public function it_can_find_and_object_with_ulid_as_id(): void persistent_factory(ManyToOneWithAutoGeneratedUlid\OwningSide::class)::random(['inverseSide' => $inverseSide]); } - /** - * @test - */ #[Test] public function it_works_with_doctrine_lifecycle_callbacks(): void { @@ -333,9 +306,6 @@ public function it_works_with_doctrine_lifecycle_callbacks(): void self::assertSame('pre-persist', $entity->prop1); } - /** - * @test - */ #[Test] public function after_persist_hook_occur_before_pre_persist_lifecycle_callback(): void { @@ -350,9 +320,6 @@ static function(EntityWithLifecycleCallback $e) { self::assertSame('foo', $entity->prop2); } - /** - * @test - */ #[Test] public function it_can_declare_after_instantiate_properties_that_occur_after_pre_persist(): void { @@ -367,9 +334,6 @@ static function(EntityWithLifecycleCallback $e) { self::assertSame('pre-persist - after instantiate', $entity->prop1); } - /** - * @test - */ #[Test] public function inversed_multiple_mandatory_relationship_to_same_entity(): void { diff --git a/tests/Integration/ORM/EmbeddableEntityFactoryTest.php b/tests/Integration/ORM/EmbeddableEntityFactoryTest.php index 258dea8ff..c383033cf 100644 --- a/tests/Integration/ORM/EmbeddableEntityFactoryTest.php +++ b/tests/Integration/ORM/EmbeddableEntityFactoryTest.php @@ -11,20 +11,19 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; use Zenstruck\Foundry\Tests\Fixture\Entity\WithEmbeddableEntity; use Zenstruck\Foundry\Tests\Integration\Persistence\EmbeddableFactoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\persistent_factory; /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('DATABASE_URL')] final class EmbeddableEntityFactoryTest extends EmbeddableFactoryTestCase { - use RequiresORM; - protected function withEmbeddableFactory(): PersistentObjectFactory { return persistent_factory(WithEmbeddableEntity::class); // @phpstan-ignore return.type diff --git a/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php b/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php index c8501d123..cea9e97af 100644 --- a/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php +++ b/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php @@ -14,7 +14,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings; -use PHPUnit\Framework\Attributes\RequiresPhpunit; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; @@ -39,15 +39,13 @@ /** * @author Kevin Bond * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.4 */ -#[RequiresPhpunit('>=11.4')] +#[RequiresEnvironmentVariable('DATABASE_URL')] #[ResetDatabase] abstract class EntityFactoryRelationshipTestCase extends KernelTestCase { use ChangesEntityRelationshipCascadePersist; - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -65,7 +63,6 @@ public function many_to_one(): void $this->assertNotNull($contact->getCategory()?->id); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -75,7 +72,6 @@ public function one_to_many_with_factory_collection(): void $this->one_to_many(static::contactFactory()->many(2)); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -90,7 +86,6 @@ public function create_many_one_to_many_with_factory_collection(): void CategoryFactory::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -100,7 +95,6 @@ public function one_to_many_with_array_of_factories(): void $this->one_to_many([static::contactFactory(), static::contactFactory()]); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -110,7 +104,6 @@ public function one_to_many_with_array_of_managed_objects(): void $this->one_to_many([static::contactFactoryWithoutCategory()->create(), static::contactFactoryWithoutCategory()->create()]); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -133,7 +126,6 @@ public function inverse_one_to_many_relationship(): void } } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -143,7 +135,6 @@ public function many_to_many_owning(): void $this->many_to_many(static::contactFactory()->many(3)); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -153,7 +144,6 @@ public function many_to_many_owning_as_array(): void $this->many_to_many([static::contactFactory(), static::contactFactory(), static::contactFactory()]); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -175,7 +165,6 @@ public function many_to_many_inverse(): void } } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -191,7 +180,6 @@ public function one_to_one_owning(): void $this->assertNotNull($contact->getAddress()->id); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -207,7 +195,6 @@ public function inversed_one_to_one(): void static::contactFactory()::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -225,7 +212,6 @@ public function many_to_one_unmanaged_raw_entity(): void $this->assertSame('Some city', $contact->getAddress()->getCity()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -254,7 +240,6 @@ public function one_to_many_with_two_relationships_same_entity(): void } } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -273,7 +258,6 @@ public function one_to_many_with_two_relationships_same_entity_and_adders(): voi static::categoryFactory()::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -294,7 +278,6 @@ public function inverse_many_to_many_with_two_relationships_same_entity(): void static::tagFactory()::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -309,7 +292,6 @@ public function can_use_adder_as_attributes(): void self::assertSame('foo', $category->getContacts()[0]?->getName()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -331,7 +313,6 @@ public function forced_one_to_many_with_doctrine_collection_type(): void static::categoryFactory()::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -361,7 +342,6 @@ public function disabling_persistence_cascades_to_children(): void } } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -386,7 +366,6 @@ public function disabling_persistence_cascades_to_children_one_to_many(): void } } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -408,7 +387,6 @@ public function disabling_persistence_cascades_to_children_inversed_one_to_one() $this->assertNull($address->getContact()->id); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -434,7 +412,6 @@ public function ensure_one_to_many_relations_are_not_pre_persisted(): void } } - /** @test */ #[Test] public function assert_updates_are_implicitly_persisted(): void { @@ -449,7 +426,6 @@ public function assert_updates_are_implicitly_persisted(): void self::assertSame('new name', $category->getName()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -461,7 +437,6 @@ public function it_can_add_managed_entity_to_many_to_one(): void ); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -473,7 +448,6 @@ public function it_can_add_unmanaged_entity_to_many_to_one(): void ); } - /** @test */ #[Test] public function it_uses_after_persist_with_many_to_many(): void { @@ -490,7 +464,6 @@ public function it_uses_after_persist_with_many_to_many(): void self::assertEquals('foobar', $contact->getTags()[0]?->getName()); } - /** @test */ #[Test] public function it_uses_after_persist_with_one_to_many(): void { @@ -506,7 +479,6 @@ public function it_uses_after_persist_with_one_to_many(): void self::assertEquals('foobar', $category->getContacts()[0]?->getName()); } - /** @test */ #[Test] public function it_uses_after_persist_with_many_to_one(): void { @@ -521,7 +493,6 @@ public function it_uses_after_persist_with_many_to_one(): void self::assertEquals('foobar', $contact->getCategory()?->getName()); } - /** @test */ #[Test] public function it_uses_after_persist_with_one_to_one(): void { @@ -534,7 +505,6 @@ public function it_uses_after_persist_with_one_to_one(): void self::assertEquals('foobar', $contact->getAddress()->getCity()); } - /** @test */ #[Test] public function it_uses_after_persist_with_inversed_one_to_one(): void { @@ -547,7 +517,6 @@ public function it_uses_after_persist_with_inversed_one_to_one(): void self::assertEquals('foobar', $address->getContact()?->getName()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -566,7 +535,6 @@ public function can_call_create_in_after_persist_callback(): void self::assertSame($category, $category->getContacts()[0]?->getCategory()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -585,7 +553,6 @@ public function can_use_nested_after_persist_callback(): void self::assertSame('city from after persist', $contact->getAddress()->getCity()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -606,7 +573,6 @@ public function can_call_create_in_nested_after_persist_callback(): void self::assertCount(1, $contact->getCategory()?->getSecondaryContacts() ?? []); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -635,7 +601,6 @@ static function(array $attributes): array { self::assertNotNull($address->getContact()->getCategory()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -659,7 +624,6 @@ public function inverse_one_to_one_with_lazy_flush(): void self::assertNotNull($address->getContact()->getCategory()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -681,7 +645,6 @@ static function(Category $c): void { self::assertNotNull($category->getContacts()[0] ?? null); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -705,7 +668,6 @@ static function(Category $c): void { self::assertNotNull($category->getContacts()[1] ?? null); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -727,7 +689,6 @@ static function(Contact $c): void { self::assertCount(1, $contact->getCategory()->getContacts()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -744,7 +705,6 @@ static function(Address $a): void { self::assertNotNull($address->getContact()); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -759,7 +719,6 @@ public function find_or_create_used_in_many_actually_create_only_one_object(): v static::categoryFactory()::assert()->count(1); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -784,7 +743,6 @@ static function() { static::categoryFactory()::assert()->count(2); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -799,8 +757,6 @@ public function call_many_with_zero_do_nothing(): void } /** - * @test - * @dataProvider provideCanUseFactoryInDataProviderWithRelationshipCases * @param PersistentObjectFactory $factory */ #[Test] @@ -812,7 +768,6 @@ public function can_create_many_with_factory_from_data_provider_with_relationshi self::assertCount(2, $objects); } - /** @test */ #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] @@ -836,10 +791,6 @@ public static function provideCanUseFactoryInDataProviderWithRelationshipCases() ]; } - /** - * @test - * @dataProvider provideIsCreatesFactoryInDataProviderWithOneToManyCases - */ #[Test] #[DataProvider('provideIsCreatesFactoryInDataProviderWithOneToManyCases')] public function is_creates_factory_in_data_provider_with_one_to_many(CategoryFactory $categoryFactory): void diff --git a/tests/Integration/ORM/EntityRelationship/PolymorphicEntityFactoryRelationshipTest.php b/tests/Integration/ORM/EntityRelationship/PolymorphicEntityFactoryRelationshipTest.php index 7c93bfd3e..903c5e3b7 100644 --- a/tests/Integration/ORM/EntityRelationship/PolymorphicEntityFactoryRelationshipTest.php +++ b/tests/Integration/ORM/EntityRelationship/PolymorphicEntityFactoryRelationshipTest.php @@ -11,7 +11,6 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM\EntityRelationship; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Address\AddressFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Category\CategoryFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ChildContactFactory; @@ -23,7 +22,6 @@ * @author Kevin Bond * @author Nicolas PHILIPPE */ -#[RequiresPhpunit('>=11.4')] final class PolymorphicEntityFactoryRelationshipTest extends EntityFactoryRelationshipTestCase { protected static function contactFactory(): ChildContactFactory diff --git a/tests/Integration/ORM/EntityRelationship/StandardEntityFactoryRelationshipTest.php b/tests/Integration/ORM/EntityRelationship/StandardEntityFactoryRelationshipTest.php index f2f108281..447280dec 100644 --- a/tests/Integration/ORM/EntityRelationship/StandardEntityFactoryRelationshipTest.php +++ b/tests/Integration/ORM/EntityRelationship/StandardEntityFactoryRelationshipTest.php @@ -11,7 +11,6 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM\EntityRelationship; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Address\AddressFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Category\CategoryFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; @@ -21,7 +20,6 @@ * @author Kevin Bond * @author Nicolas PHILIPPE */ -#[RequiresPhpunit('>=11.4')] class StandardEntityFactoryRelationshipTest extends EntityFactoryRelationshipTestCase { protected static function contactFactory(): ContactFactory diff --git a/tests/Integration/ORM/GenericEntityFactoryTest.php b/tests/Integration/ORM/GenericEntityFactoryTest.php index 1038f25fc..ff4498869 100644 --- a/tests/Integration/ORM/GenericEntityFactoryTest.php +++ b/tests/Integration/ORM/GenericEntityFactoryTest.php @@ -12,12 +12,12 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\EmptyConstructorFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Fixture\Model\GenericModel; use Zenstruck\Foundry\Tests\Integration\Persistence\GenericFactoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\disable_persisting; use function Zenstruck\Foundry\Persistence\enable_persisting; @@ -25,13 +25,9 @@ /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('DATABASE_URL')] final class GenericEntityFactoryTest extends GenericFactoryTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function can_use_factory_with_empty_constructor(): void { @@ -42,9 +38,6 @@ public function can_use_factory_with_empty_constructor(): void EmptyConstructorFactory::assert()->count(1); } - /** - * @test - */ #[Test] public function can_use_factory_with_empty_constructor_without_persistence(): void { @@ -58,9 +51,6 @@ public function can_use_factory_with_empty_constructor_without_persistence(): vo } /** - * @test - * @dataProvider afterPersistDecideFlushProvider - * * @phpstan-ignore missingType.callable */ #[Test] diff --git a/tests/Integration/ORM/GenericEntityRepositoryDecoratorTest.php b/tests/Integration/ORM/GenericEntityRepositoryDecoratorTest.php index 7697460c8..2d2ae47df 100644 --- a/tests/Integration/ORM/GenericEntityRepositoryDecoratorTest.php +++ b/tests/Integration/ORM/GenericEntityRepositoryDecoratorTest.php @@ -11,21 +11,17 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Zenstruck\Foundry\Persistence\PersistentObjectFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; use Zenstruck\Foundry\Tests\Integration\Persistence\GenericRepositoryDecoratorTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; use function Zenstruck\Foundry\Persistence\repository; +#[RequiresEnvironmentVariable('DATABASE_URL')] class GenericEntityRepositoryDecoratorTest extends GenericRepositoryDecoratorTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function can_call_find_by_with_multiple_values(): void { diff --git a/tests/Integration/ORM/OrmStoryTest.php b/tests/Integration/ORM/OrmStoryTest.php index bdc261fa8..fe8065c20 100644 --- a/tests/Integration/ORM/OrmStoryTest.php +++ b/tests/Integration/ORM/OrmStoryTest.php @@ -11,6 +11,7 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Zenstruck\Foundry\Tests\Fixture\Entity\GenericEntity; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; @@ -18,18 +19,13 @@ use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; use Zenstruck\Foundry\Tests\Fixture\Stories\PersistenceDisabledStory; use Zenstruck\Foundry\Tests\Integration\Persistence\StoryTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Kevin Bond */ +#[RequiresEnvironmentVariable('DATABASE_URL')] final class OrmStoryTest extends StoryTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function can_use_story_with_persistence_disabled(): void { diff --git a/tests/Integration/ORM/PersistenceManagerTest.php b/tests/Integration/ORM/PersistenceManagerTest.php index 1aaeec6f5..916300bd0 100644 --- a/tests/Integration/ORM/PersistenceManagerTest.php +++ b/tests/Integration/ORM/PersistenceManagerTest.php @@ -13,14 +13,13 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use Zenstruck\Foundry\Tests\Fixture\Entity\EntityWithUid; use Zenstruck\Foundry\Tests\Integration\Persistence\PersistenceManagerTestCase; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; +#[RequiresEnvironmentVariable('DATABASE_URL')] final class PersistenceManagerTest extends PersistenceManagerTestCase { - use RequiresORM; - protected static function createObject(): object { return new EntityWithUid(); diff --git a/tests/Integration/ORM/ReuseEntityTest.php b/tests/Integration/ORM/ReuseEntityTest.php index 139fefb28..b20724791 100644 --- a/tests/Integration/ORM/ReuseEntityTest.php +++ b/tests/Integration/ORM/ReuseEntityTest.php @@ -11,6 +11,7 @@ namespace Zenstruck\Foundry\Tests\Integration\ORM; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; @@ -18,16 +19,11 @@ use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Category\CategoryFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Tag\TagFactory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class ReuseEntityTest extends KernelTestCase { - use RequiresORM; - - /** - * @test - */ #[Test] public function it_can_reuse_an_object_in_one_to_one(): void { @@ -40,9 +36,6 @@ public function it_can_reuse_an_object_in_one_to_one(): void self::assertSame($address, $contact->getAddress()); } - /** - * @test - */ #[Test] public function it_can_reuse_an_object_in_inverse_one_to_one(): void { @@ -55,9 +48,6 @@ public function it_can_reuse_an_object_in_inverse_one_to_one(): void self::assertSame($contact, $address->getContact()); } - /** - * @test - */ #[Test] public function it_can_propagate_reused_objects_through_inversed_one_to_one(): void { @@ -71,9 +61,6 @@ public function it_can_propagate_reused_objects_through_inversed_one_to_one(): v self::assertSame($category, $address->getContact()->getSecondaryCategory()); } - /** - * @test - */ #[Test] public function reused_object_in_sub_factory_has_priority(): void { @@ -89,9 +76,6 @@ public function reused_object_in_sub_factory_has_priority(): void self::assertSame($category2, $address->getContact()->getSecondaryCategory()); } - /** - * @test - */ #[Test] public function reuse_has_no_effect_on_collections(): void { @@ -105,9 +89,6 @@ public function reuse_has_no_effect_on_collections(): void self::assertNotSame($contact, $category->getContacts()[1]); } - /** - * @test - */ #[Test] public function it_can_propagate_reused_objects_through_inversed_one_to_many(): void { @@ -123,9 +104,6 @@ public function it_can_propagate_reused_objects_through_inversed_one_to_many(): } } - /** - * @test - */ #[Test] public function it_can_propagate_reused_objects_through_inversed_many_to_many(): void { diff --git a/tests/Integration/ObjectFactoryTest.php b/tests/Integration/ObjectFactoryTest.php index 302d65b24..6fae00dce 100644 --- a/tests/Integration/ObjectFactoryTest.php +++ b/tests/Integration/ObjectFactoryTest.php @@ -21,9 +21,6 @@ */ final class ObjectFactoryTest extends KernelTestCase { - /** - * @test - */ #[Test] public function can_create_service_factory(): void { @@ -34,9 +31,6 @@ public function can_create_service_factory(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function can_create_non_service_factories(): void { @@ -45,9 +39,6 @@ public function can_create_non_service_factories(): void $this->assertSame('router-constructor', $object->object->getProp1()); } - /** - * @test - */ #[Test] public function can_create_different_objects_based_on_same_factory(): void { diff --git a/tests/Integration/Persistence/EmbeddableFactoryTestCase.php b/tests/Integration/Persistence/EmbeddableFactoryTestCase.php index 8dc759b3d..4ecf429aa 100644 --- a/tests/Integration/Persistence/EmbeddableFactoryTestCase.php +++ b/tests/Integration/Persistence/EmbeddableFactoryTestCase.php @@ -26,7 +26,6 @@ #[ResetDatabase] abstract class EmbeddableFactoryTestCase extends KernelTestCase { - /** @test */ #[Test] public function embed_one(): void { @@ -43,9 +42,6 @@ public function embed_one(): void $this->assertSame('value1', $object->getEmbeddable()->getProp1()); } - /** - * @test - */ #[Test] public function can_find_using_embeddable_object(): void { @@ -60,9 +56,6 @@ public function can_find_using_embeddable_object(): void $this->assertSame(0, $factory::count(['embeddable' => factory(Embeddable::class, ['prop1' => 'value2'])])); } - /** - * @test - */ #[Test] public function can_use_embeddable_as_factory_parameter(): void { diff --git a/tests/Integration/Persistence/FactoryWithHooksInInitializeTest.php b/tests/Integration/Persistence/FactoryWithHooksInInitializeTest.php index 41fd8ad00..03f87f61f 100644 --- a/tests/Integration/Persistence/FactoryWithHooksInInitializeTest.php +++ b/tests/Integration/Persistence/FactoryWithHooksInInitializeTest.php @@ -20,9 +20,6 @@ */ final class FactoryWithHooksInInitializeTest extends KernelTestCase { - /** - * @test - */ #[Test] public function it_can_access_current_factory_in_hooks(): void { diff --git a/tests/Integration/Persistence/GenericFactoryTestCase.php b/tests/Integration/Persistence/GenericFactoryTestCase.php index 5d888d055..5d2b484de 100644 --- a/tests/Integration/Persistence/GenericFactoryTestCase.php +++ b/tests/Integration/Persistence/GenericFactoryTestCase.php @@ -38,9 +38,6 @@ #[ResetDatabase] abstract class GenericFactoryTestCase extends KernelTestCase { - /** - * @test - */ #[Test] public function can_create_and_update(): void { @@ -67,9 +64,6 @@ public function can_create_and_update(): void static::factory()::assert()->exists(['prop1' => 'new value']); } - /** - * @test - */ #[Test] public function can_disable_auto_persist(): void { @@ -87,9 +81,6 @@ public function can_disable_auto_persist(): void static::factory()->repository()->assert()->exists(['prop1' => 'default1']); } - /** - * @test - */ #[Test] public function can_refresh(): void { @@ -115,9 +106,6 @@ public function can_refresh(): void static::factory()->repository()->assert()->exists(['prop1' => 'external']); } - /** - * @test - */ #[Test] public function cannot_refresh_if_there_are_unsaved_changes(): void { @@ -140,9 +128,6 @@ public function cannot_refresh_if_there_are_unsaved_changes(): void $this->fail('Exception not thrown'); } - /** - * @test - */ #[Test] public function can_delete(): void { @@ -155,9 +140,6 @@ public function can_delete(): void static::factory()->repository()->assert()->empty(); } - /** - * @test - */ #[Test] public function repository_and_create_function(): void { @@ -171,9 +153,6 @@ public function repository_and_create_function(): void repository($this->modelClass())->assert()->count(1); } - /** - * @test - */ #[Test] public function create_many(): void { @@ -186,9 +165,6 @@ public function create_many(): void $this->assertSame('value3', $models[2]->getProp1()); } - /** - * @test - */ #[Test] public function find(): void { @@ -198,9 +174,6 @@ public function find(): void $this->assertSame($object->id, static::factory()::find(['prop1' => 'foo'])->id); } - /** - * @test - */ #[Test] public function find_must_return_object(): void { @@ -209,9 +182,6 @@ public function find_must_return_object(): void static::factory()::find(1); } - /** - * @test - */ #[Test] public function find_by(): void { @@ -223,9 +193,6 @@ public function find_by(): void $this->assertCount(2, static::factory()::findBy(['prop1' => 'b'])); } - /** - * @test - */ #[Test] public function find_or_create(): void { @@ -240,9 +207,6 @@ public function find_or_create(): void static::factory()::repository()->assert()->count(2); } - /** - * @test - */ #[Test] public function random(): void { @@ -254,9 +218,6 @@ public function random(): void $this->assertSame('b', static::factory()::random(['prop1' => 'b'])->getProp1()); } - /** - * @test - */ #[Test] public function random_must_return_an_object(): void { @@ -265,9 +226,6 @@ public function random_must_return_an_object(): void static::factory()::random(); } - /** - * @test - */ #[Test] public function random_or_create(): void { @@ -283,9 +241,6 @@ public function random_or_create(): void static::factory()::repository()->assert()->count(2); } - /** - * @test - */ #[Test] public function random_range_or_create_enough_object(): void { @@ -303,9 +258,6 @@ public function random_range_or_create_enough_object(): void } } - /** - * @test - */ #[Test] public function random_range_or_create_not_enough_object(): void { @@ -320,9 +272,6 @@ public function random_range_or_create_not_enough_object(): void ->exists(['prop1' => 'default1']); } - /** - * @test - */ #[Test] public function random_range_or_create_not_enough_object_with_criteria(): void { @@ -339,9 +288,6 @@ public function random_range_or_create_not_enough_object_with_criteria(): void } } - /** - * @test - */ #[Test] public function random_range_or_create_no_object_with_criteria(): void { @@ -358,9 +304,6 @@ public function random_range_or_create_no_object_with_criteria(): void } } - /** - * @test - */ #[Test] public function random_set(): void { @@ -381,9 +324,6 @@ public function random_set(): void $this->assertSame('b', $set[1]->getProp1()); } - /** - * @test - */ #[Test] public function random_set_requires_at_least_the_number_available(): void { @@ -394,9 +334,6 @@ public function random_set_requires_at_least_the_number_available(): void static::factory()::randomSet(4); } - /** - * @test - */ #[Test] public function random_range(): void { @@ -424,9 +361,6 @@ public function random_range(): void } } - /** - * @test - */ #[Test] public function random_range_requires_at_least_the_max_available(): void { @@ -437,9 +371,6 @@ public function random_range_requires_at_least_the_max_available(): void static::factory()::randomRange(1, 5); } - /** - * @test - */ #[Test] public function factory_count(): void { @@ -451,9 +382,6 @@ public function factory_count(): void $this->assertSame(2, static::factory()::count(['prop1' => 'b'])); } - /** - * @test - */ #[Test] public function truncate(): void { @@ -465,9 +393,6 @@ public function truncate(): void static::factory()::repository()->assert()->empty(); } - /** - * @test - */ #[Test] public function factory_all(): void { @@ -476,9 +401,6 @@ public function factory_all(): void $this->assertCount(3, static::factory()::all()); } - /** - * @test - */ #[Test] public function repository_assertions(): void { @@ -510,9 +432,6 @@ public function repository_assertions(): void $assert->notExists(999); } - /** - * @test - */ #[Test] public function repository_is_lazy(): void { @@ -529,9 +448,6 @@ public function repository_is_lazy(): void $repository->assert()->exists(['prop1' => 'new value']); } - /** - * @test - */ #[Test] public function flush_after(): void { @@ -553,9 +469,6 @@ public function flush_after(): void self::assertSame($object, $return); } - /** - * @test - */ #[Test] public function can_disable_and_enable_persisting_globally(): void { @@ -574,9 +487,6 @@ public function can_disable_and_enable_persisting_globally(): void static::factory()::repository()->assert()->count(1); } - /** - * @test - */ #[Test] public function cannot_access_repository_method_when_persist_disabled(): void { @@ -604,9 +514,6 @@ public function cannot_access_repository_method_when_persist_disabled(): void self::assertSame(3, $countErrors); } - /** - * @test - */ #[Test] public function can_persist_object_with_sequence(): void { @@ -617,10 +524,6 @@ public function can_persist_object_with_sequence(): void static::factory()::assert()->exists(['prop1' => 'bar']); } - /** - * @test - * @depends cannot_access_repository_method_when_persist_disabled - */ #[Test] #[Depends('cannot_access_repository_method_when_persist_disabled')] public function assert_persist_is_re_enabled_automatically(): void @@ -633,9 +536,6 @@ public function assert_persist_is_re_enabled_automatically(): void static::factory()::assert()->count(1); } - /** - * @test - */ #[Test] public function assert_it_ca_create_object_with_dates(): void { @@ -643,9 +543,6 @@ public function assert_it_ca_create_object_with_dates(): void self::assertSame($date->format(\DateTimeInterface::ATOM), $object->getDate()?->format(\DateTimeInterface::ATOM)); } - /** - * @test - */ #[Test] public function can_use_after_persist_with_attributes(): void { @@ -663,9 +560,6 @@ public function can_use_after_persist_with_attributes(): void $this->assertSame(1, $object->getPropInteger()); } - /** - * @test - */ #[Test] public function it_actually_calls_post_persist_hook_after_persist_when_in_flush_after(): void { @@ -682,9 +576,6 @@ static function(GenericModel $o) { self::assertSame((string) $object->id, $object->getProp1()); } - /** - * @test - */ #[Test] public function it_actually_calls_post_persist_hook_after_persist_when_in_create_many(): void { @@ -700,9 +591,6 @@ static function(GenericModel $o) { } } - /** - * @test - */ #[Test] public function can_use_priorities_in_hooks(): void { diff --git a/tests/Integration/Persistence/GenericFactoryUsingBeforeHooksTest.php b/tests/Integration/Persistence/GenericFactoryUsingBeforeHooksTest.php index aae21459a..e653c1993 100644 --- a/tests/Integration/Persistence/GenericFactoryUsingBeforeHooksTest.php +++ b/tests/Integration/Persistence/GenericFactoryUsingBeforeHooksTest.php @@ -12,51 +12,42 @@ namespace Zenstruck\Foundry\Tests\Integration\Persistence; use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE */ #[ResetDatabase] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class GenericFactoryUsingBeforeHooksTest extends KernelTestCase { - use RequiresORM; - protected function setUp(): void { GenericEntityFactory::createOne(); } - /** @before */ #[Before(1)] public function beforeSetup(): void { $this->setUp(); } - /** @before */ #[Before(-1)] public function afterSetup(): void { $this->setUp(); } - /** - * @test - */ #[Test] public function assert_objects_created(): void { GenericEntityFactory::assert()->count(3); } - /** - * @test - */ #[Test] public function assert_objects_created_2(): void { diff --git a/tests/Integration/Persistence/GenericRepositoryDecoratorTestCase.php b/tests/Integration/Persistence/GenericRepositoryDecoratorTestCase.php index d2cc9a673..8f3245ba0 100644 --- a/tests/Integration/Persistence/GenericRepositoryDecoratorTestCase.php +++ b/tests/Integration/Persistence/GenericRepositoryDecoratorTestCase.php @@ -22,9 +22,6 @@ #[ResetDatabase] abstract class GenericRepositoryDecoratorTestCase extends KernelTestCase { - /** - * @test - */ #[Test] public function repository_is_countable_and_iterable(): void { @@ -36,9 +33,6 @@ public function repository_is_countable_and_iterable(): void $this->assertCount(4, \iterator_to_array($repository)); } - /** - * @test - */ #[Test] public function can_fetch_objects(): void { @@ -55,9 +49,6 @@ public function can_fetch_objects(): void $this->assertInstanceOf($this->modelClass(), $objects[0]); } - /** - * @test - */ #[Test] public function can_call_find_with_empty_array(): void { diff --git a/tests/Integration/Persistence/PersistenceManagerTestCase.php b/tests/Integration/Persistence/PersistenceManagerTestCase.php index 6e232d4be..d616db280 100644 --- a/tests/Integration/Persistence/PersistenceManagerTestCase.php +++ b/tests/Integration/Persistence/PersistenceManagerTestCase.php @@ -18,9 +18,6 @@ abstract class PersistenceManagerTestCase extends KernelTestCase { - /** - * @test - */ #[Test] public function it_can_test_if_object_with_uuid_is_persisted(): void { diff --git a/tests/Integration/Persistence/StoryTestCase.php b/tests/Integration/Persistence/StoryTestCase.php index b772efbf6..9cb2e52f9 100644 --- a/tests/Integration/Persistence/StoryTestCase.php +++ b/tests/Integration/Persistence/StoryTestCase.php @@ -29,9 +29,6 @@ #[ResetDatabase] abstract class StoryTestCase extends KernelTestCase { - /** - * @test - */ #[Test] public function stories_only_loaded_once(): void { @@ -44,9 +41,6 @@ public function stories_only_loaded_once(): void static::factoryClass()::repository()->assert()->count(2); } - /** - * @test - */ #[Test] public function can_access_story_state(): void { @@ -62,9 +56,6 @@ public function can_access_story_state(): void $this->assertNull($story::get('null')); } - /** - * @test - */ #[Test] public function can_access_story_state_with_magic_call(): void { @@ -80,9 +71,6 @@ public function can_access_story_state_with_magic_call(): void $this->assertNull($story::null()); } - /** - * @test - */ #[Test] public function can_access_story_state_with_magic_call_on_instance(): void { @@ -98,9 +86,6 @@ public function can_access_story_state_with_magic_call_on_instance(): void $this->assertNull($story::load()->null()); } - /** - * @test - */ #[Test] public function cannot_access_invalid_object(): void { @@ -109,9 +94,6 @@ public function cannot_access_invalid_object(): void static::storyClass()::get('invalid'); } - /** - * @test - */ #[Test] public function can_get_random_object_set_from_pool(): void { @@ -122,9 +104,6 @@ public function can_get_random_object_set_from_pool(): void $this->assertCount(2, $objects); } - /** - * @test - */ #[Test] public function can_get_random_object_from_pool(): void { @@ -139,9 +118,6 @@ public function can_get_random_object_from_pool(): void $this->assertCount(3, \array_unique($ids)); } - /** - * @test - */ #[Test] public function can_get_random_object_range_from_pool(): void { @@ -161,9 +137,6 @@ public function can_get_random_object_range_from_pool(): void $this->assertNotContains(4, $counts); } - /** - * @test - */ #[Test] public function story_can_access_its_own_pool(): void { @@ -176,9 +149,6 @@ public function story_can_access_its_own_pool(): void self::assertContains($item->getProp1(), ['foo', 'default1']); } - /** - * @test - */ #[Test] public function can_use_story_with_simple_object(): void { diff --git a/tests/Integration/RequiresMongo.php b/tests/Integration/RequiresMongo.php deleted file mode 100644 index 9af65c4c2..000000000 --- a/tests/Integration/RequiresMongo.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Zenstruck\Foundry\Tests\Integration; - -use PHPUnit\Framework\Attributes\BeforeClass; - -/** - * @author Kevin Bond - */ -trait RequiresMongo -{ - /** - * @beforeClass - */ - #[BeforeClass] - public static function _requiresMongo(): void - { - if (!\getenv('MONGO_URL')) { - self::markTestSkipped('MongoDB not available.'); - } - } -} diff --git a/tests/Integration/RequiresORM.php b/tests/Integration/RequiresORM.php deleted file mode 100644 index fe318f9f5..000000000 --- a/tests/Integration/RequiresORM.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Zenstruck\Foundry\Tests\Integration; - -use PHPUnit\Framework\Attributes\BeforeClass; - -/** - * @author Kevin Bond - */ -trait RequiresORM -{ - /** - * @beforeClass - */ - #[BeforeClass] - public static function _requiresOrm(): void - { - if (!\getenv('DATABASE_URL')) { - self::markTestSkipped('SQL database not available.'); - } - - parent::setUpBeforeClass(); - } -} diff --git a/tests/Integration/ResetDatabase/EarlyBootedKernelTest.php b/tests/Integration/ResetDatabase/EarlyBootedKernelTest.php index 23486c046..81721679d 100644 --- a/tests/Integration/ResetDatabase/EarlyBootedKernelTest.php +++ b/tests/Integration/ResetDatabase/EarlyBootedKernelTest.php @@ -14,16 +14,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\Middleware; use PHPUnit\Framework\Attributes\BeforeClass; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\ResetDatabase\DoctrineMiddleware; use Zenstruck\Foundry\Tests\Fixture\ResetDatabase\ResetDatabaseTestKernel; #[ResetDatabase] -#[RequiresPhpunitExtension(FoundryExtension::class)] final class EarlyBootedKernelTest extends KernelTestCase { /** diff --git a/tests/Integration/ResetDatabase/GlobalStoryTest.php b/tests/Integration/ResetDatabase/GlobalStoryTest.php index afdaf9fa2..81cd170fd 100644 --- a/tests/Integration/ResetDatabase/GlobalStoryTest.php +++ b/tests/Integration/ResetDatabase/GlobalStoryTest.php @@ -11,11 +11,9 @@ namespace Zenstruck\Foundry\Tests\Integration\ResetDatabase; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Document\GlobalDocument; use Zenstruck\Foundry\Tests\Fixture\Entity\GlobalEntity; use Zenstruck\Foundry\Tests\Fixture\FoundryTestKernel; @@ -25,7 +23,6 @@ use function Zenstruck\Foundry\Persistence\repository; #[ResetDatabase] -#[RequiresPhpunitExtension(FoundryExtension::class)] final class GlobalStoryTest extends KernelTestCase { #[Test] diff --git a/tests/Integration/ResetDatabase/OrmEdgeCaseTest.php b/tests/Integration/ResetDatabase/OrmEdgeCaseTest.php index 5c0b0089a..d186914d1 100644 --- a/tests/Integration/ResetDatabase/OrmEdgeCaseTest.php +++ b/tests/Integration/ResetDatabase/OrmEdgeCaseTest.php @@ -13,12 +13,10 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\ChangesEntityRelationshipCascadePersist; use Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\UsingRelationships; use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\RelationshipWithGlobalEntity; @@ -30,8 +28,8 @@ use function Zenstruck\Foundry\Persistence\flush_after; use function Zenstruck\Foundry\Persistence\persistent_factory; +#[RequiresEnvironmentVariable('DATABASE_URL')] #[ResetDatabase] -#[RequiresPhpunitExtension(FoundryExtension::class)] final class OrmEdgeCaseTest extends KernelTestCase { use ChangesEntityRelationshipCascadePersist; @@ -39,7 +37,6 @@ final class OrmEdgeCaseTest extends KernelTestCase #[Test] #[DataProvider('provideCascadeRelationshipsCombinations')] #[UsingRelationships(RelationshipWithGlobalEntity\RelationshipWithGlobalEntity::class, ['globalEntity'])] - #[RequiresPhpunit('>=11.4')] #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] public function it_can_use_flush_after_and_entity_from_global_state(): void { diff --git a/tests/Integration/ResetDatabase/ResetDatabaseTest.php b/tests/Integration/ResetDatabase/ResetDatabaseTest.php index 0a0485eb5..4f2265b01 100644 --- a/tests/Integration/ResetDatabase/ResetDatabaseTest.php +++ b/tests/Integration/ResetDatabase/ResetDatabaseTest.php @@ -12,7 +12,6 @@ namespace Zenstruck\Foundry\Tests\Integration\ResetDatabase; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -20,7 +19,6 @@ use Symfony\Component\Console\Output\BufferedOutput; use Zenstruck\Foundry\Attribute\ResetDatabase; use Zenstruck\Foundry\Persistence\PersistenceManager; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\EntityInAnotherSchema\Article; use Zenstruck\Foundry\Tests\Fixture\Factories\Document\GenericDocumentFactory; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; @@ -36,7 +34,6 @@ * @author Nicolas PHILIPPE */ #[ResetDatabase] -#[RequiresPhpunitExtension(FoundryExtension::class)] final class ResetDatabaseTest extends KernelTestCase { #[Test] diff --git a/tests/Unit/ArrayFactoryTest.php b/tests/Unit/ArrayFactoryTest.php index 41b1d6c90..f3564af68 100644 --- a/tests/Unit/ArrayFactoryTest.php +++ b/tests/Unit/ArrayFactoryTest.php @@ -21,9 +21,6 @@ */ final class ArrayFactoryTest extends TestCase { - /** - * @test - */ #[Test] public function can_create_with_defaults(): void { @@ -38,9 +35,6 @@ public function can_create_with_defaults(): void ); } - /** - * @test - */ #[Test] public function can_create_with_overrides(): void { @@ -58,9 +52,6 @@ public function can_create_with_overrides(): void ); } - /** - * @test - */ #[Test] public function can_create_many(): void { @@ -76,9 +67,6 @@ public function can_create_many(): void ); } - /** - * @test - */ #[Test] public function can_create_range(): void { @@ -88,9 +76,6 @@ public function can_create_range(): void $this->assertLessThanOrEqual(4, \count($range)); } - /** - * @test - */ #[Test] public function can_create_sequence(): void { diff --git a/tests/Unit/FactoryCollectionTest.php b/tests/Unit/FactoryCollectionTest.php index 4ef2ac947..5e20e5c57 100644 --- a/tests/Unit/FactoryCollectionTest.php +++ b/tests/Unit/FactoryCollectionTest.php @@ -18,9 +18,6 @@ final class FactoryCollectionTest extends TestCase { - /** - * @test - */ #[Test] public function throws_when_method_does_not_exist(): void { @@ -32,9 +29,6 @@ public function throws_when_method_does_not_exist(): void ->applyStateMethod('nonExistentMethod', static fn() => []); } - /** - * @test - */ #[Test] public function throws_when_method_is_static(): void { @@ -46,11 +40,6 @@ public function throws_when_method_is_static(): void ->applyStateMethod('class', static fn() => []); } - /** - * @test - * @testWith [[]] - * [["a", "b"]] - */ #[Test] #[TestWith([[]])] #[TestWith([['a', 'b']])] @@ -66,9 +55,6 @@ public function throws_when_parameter_number_do_not_match(array $parametersRetur ; } - /** - * @test - */ #[Test] public function throws_when_does_not_return_static(): void { @@ -82,9 +68,6 @@ public function throws_when_does_not_return_static(): void ; } - /** - * @test - */ #[Test] public function can_call_state_method_without_parameter(): void { @@ -98,9 +81,6 @@ public function can_call_state_method_without_parameter(): void self::assertSame(42, $objects[1]->param); } - /** - * @test - */ #[Test] public function can_call_state_method_with_parameter(): void { @@ -114,9 +94,6 @@ public function can_call_state_method_with_parameter(): void self::assertSame(2, $objects[1]->param); } - /** - * @test - */ #[Test] public function can_call_state_method_with_named_parameter(): void { @@ -130,9 +107,6 @@ public function can_call_state_method_with_named_parameter(): void self::assertSame(40, $objects[1]->param); } - /** - * @test - */ #[Test] public function throws_when_called_with_not_existing_named_parameter(): void { diff --git a/tests/Unit/FactoryTest.php b/tests/Unit/FactoryTest.php index eaa3bfca4..c807e1973 100644 --- a/tests/Unit/FactoryTest.php +++ b/tests/Unit/FactoryTest.php @@ -35,9 +35,6 @@ protected function tearDown(): void Configuration::boot(UnitTestConfig::build()); } - /** - * @test - */ #[Test] public function can_register_custom_faker(): void { @@ -49,9 +46,6 @@ public function can_register_custom_faker(): void $this->assertNotSame(faker(), $defaultFaker); } - /** - * @test - */ #[Test] public function can_use_arrays_for_attribute_values(): void { @@ -64,9 +58,6 @@ public function can_use_arrays_for_attribute_values(): void $this->assertSame(['foo' => 'bar'], $factory->value); } - /** - * @test - */ #[Test] public function can_register_default_instantiator(): void { @@ -81,9 +72,6 @@ public function can_register_default_instantiator(): void $this->assertSame('different prop2-constructor', $object->getProp2()); } - /** - * @test - */ #[Test] public function instantiating_with_factory_attribute_instantiates_the_factory(): void { @@ -94,9 +82,6 @@ public function instantiating_with_factory_attribute_instantiates_the_factory(): $this->assertInstanceOf(Category::class, $object->getCategory()); } - /** - * @test - */ #[Test] public function can_use_factory_with_empty_constructor(): void { diff --git a/tests/Unit/FakerAdapterTest.php b/tests/Unit/FakerAdapterTest.php index fea8853ae..e17548e35 100644 --- a/tests/Unit/FakerAdapterTest.php +++ b/tests/Unit/FakerAdapterTest.php @@ -12,16 +12,13 @@ namespace Zenstruck\Foundry\Tests\Unit; use Faker; -use PHPUnit\Framework\Attributes\RequiresPhpunit; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Zenstruck\Foundry\FakerAdapter; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11.0 */ -#[RequiresPhpunit('>=11.0')] final class FakerAdapterTest extends TestCase { private ?int $backupSeed; diff --git a/tests/Unit/InstantiatorTest.php b/tests/Unit/InstantiatorTest.php index 69870ff8f..b1648da5f 100644 --- a/tests/Unit/InstantiatorTest.php +++ b/tests/Unit/InstantiatorTest.php @@ -17,9 +17,6 @@ final class InstantiatorTest extends TestCase { - /** - * @test - */ #[Test] public function can_set_variadic_constructor_attributes(): void { diff --git a/tests/Unit/LazyValueTest.php b/tests/Unit/LazyValueTest.php index 299cc2707..f6a5f095e 100644 --- a/tests/Unit/LazyValueTest.php +++ b/tests/Unit/LazyValueTest.php @@ -23,9 +23,6 @@ */ final class LazyValueTest extends TestCase { - /** - * @test - */ #[Test] public function lazy(): void { @@ -34,9 +31,6 @@ public function lazy(): void $this->assertNotSame($value(), $value()); } - /** - * @test - */ #[Test] public function memoize(): void { @@ -45,9 +39,6 @@ public function memoize(): void $this->assertSame($value(), $value()); } - /** - * @test - */ #[Test] public function can_handle_nested_lazy_values(): void { @@ -56,9 +47,6 @@ public function can_handle_nested_lazy_values(): void $this->assertSame('foo', $value()); } - /** - * @test - */ #[Test] public function can_handle_array_with_lazy_values(): void { diff --git a/tests/Unit/Object/HydratorTest.php b/tests/Unit/Object/HydratorTest.php index 6715ef8a7..0c5dd71ec 100644 --- a/tests/Unit/Object/HydratorTest.php +++ b/tests/Unit/Object/HydratorTest.php @@ -25,9 +25,6 @@ */ class HydratorTest extends TestCase { - /** - * @test - */ #[Test] public function can_hydrate_scalar(): void { @@ -42,9 +39,6 @@ public function can_hydrate_scalar(): void $this->assertSame($value, $object->foo); } - /** - * @test - */ #[Test] public function can_hydrate_scalar_array(): void { @@ -59,9 +53,6 @@ public function can_hydrate_scalar_array(): void $this->assertSame($value, $object->foo); } - /** - * @test - */ #[Test] public function can_hydrate_object(): void { @@ -81,9 +72,6 @@ public function __construct() $this->assertSame($value, $object->foo); } - /** - * @test - */ #[Test] public function can_hydrate_object_array(): void { @@ -102,9 +90,6 @@ public function can_hydrate_object_array(): void $this->assertSame($value, $object->foo); } - /** - * @test - */ #[Test] public function can_hydrate_doctrine_collection(): void { @@ -129,9 +114,6 @@ public function __construct() $this->assertSame($value, $object->foo->toArray()); } - /** - * @test - */ #[Test] public function can_hydrate_doctrine_collection_union(): void { @@ -156,9 +138,6 @@ public function __construct() $this->assertSame($value, $object->foo->toArray()); } - /** - * @test - */ #[Test] public function can_hydrate_doctrine_collection_intersection(): void { @@ -183,9 +162,6 @@ public function __construct() $this->assertSame($value, $object->foo->toArray()); } - /** - * @test - */ #[Test] public function can_hydrate_with_force_value(): void { @@ -203,9 +179,6 @@ public function getFoo(): string $this->assertSame('foo', $object->getFoo()); } - /** - * @test - */ #[Test] public function can_force_set_with_force_value(): void { diff --git a/tests/Unit/ObjectFactoryTest.php b/tests/Unit/ObjectFactoryTest.php index 7f6b8e290..332c6c241 100644 --- a/tests/Unit/ObjectFactoryTest.php +++ b/tests/Unit/ObjectFactoryTest.php @@ -34,9 +34,6 @@ */ final class ObjectFactoryTest extends TestCase { - /** - * @test - */ #[Test] public function defaults(): void { @@ -47,9 +44,6 @@ public function defaults(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function named_constructor_defaults(): void { @@ -60,9 +54,6 @@ public function named_constructor_defaults(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function default_instantiator_and_hydrator(): void { @@ -77,9 +68,6 @@ public function default_instantiator_and_hydrator(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function without_constructor_instantiator(): void { @@ -94,9 +82,6 @@ public function without_constructor_instantiator(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function with_closure_factory_constructor(): void { @@ -114,9 +99,6 @@ public function with_closure_factory_constructor(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function with_method_factory_constructor(): void { @@ -134,9 +116,6 @@ public function with_method_factory_constructor(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function with_named_constructor_instantiator(): void { @@ -151,9 +130,6 @@ public function with_named_constructor_instantiator(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function with_extra_and_force_mode_without_constructor(): void { @@ -172,9 +148,6 @@ public function with_extra_and_force_mode_without_constructor(): void $this->assertSame('override3', $object->getProp3()); } - /** - * @test - */ #[Test] public function can_use_force_helper_to_force_a_single_property(): void { @@ -188,9 +161,6 @@ public function can_use_force_helper_to_force_a_single_property(): void $this->assertSame('override1', $object->getProp1()); } - /** - * @test - */ #[Test] public function force_helper_used_in_constructor_does_not_throw(): void { @@ -203,9 +173,6 @@ public function force_helper_used_in_constructor_does_not_throw(): void $this->assertSame('override1-constructor', $object->getProp1()); } - /** - * @test - */ #[Test] public function force_helper_used_in_named_constructor_does_not_throw(): void { @@ -216,9 +183,6 @@ public function force_helper_used_in_named_constructor_does_not_throw(): void $this->assertSame('override1-named-constructor', $object->getProp1()); } - /** - * @test - */ #[Test] public function with_configured_hydrator(): void { @@ -237,9 +201,6 @@ public function with_configured_hydrator(): void $this->assertSame('override3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function with_hydration_disabled(): void { @@ -258,9 +219,6 @@ public function with_hydration_disabled(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function with_custom_instantiator_callable(): void { @@ -279,9 +237,6 @@ public function with_custom_instantiator_callable(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function before_instantiate_hook(): void { @@ -304,9 +259,6 @@ public function before_instantiate_hook(): void $this->assertSame('custom3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function after_instantiate_hook(): void { @@ -324,9 +276,6 @@ public function after_instantiate_hook(): void $this->assertSame('custom3-setter', $object->getProp3()); } - /** - * @test - */ #[Test] public function create_anonymous_factory(): void { @@ -349,9 +298,6 @@ public function create_anonymous_factory(): void $this->assertNull($object->getProp3()); } - /** - * @test - */ #[Test] public function object_factories_are_converted(): void { @@ -360,9 +306,6 @@ public function object_factories_are_converted(): void $this->assertSame('value1-constructor', $object->object->getProp1()); } - /** - * @test - */ #[Test] public function can_create_many(): void { @@ -381,9 +324,6 @@ public function can_create_many(): void $this->assertSame('value3-constructor', $objects[2]->getProp1()); } - /** - * @test - */ #[Test] public function set_and_get_functions(): void { @@ -397,11 +337,7 @@ public function set_and_get_functions(): void } /** - * @dataProvider sequenceDataProvider - * * @param Sequence $sequence - * - * @test */ #[Test] #[DataProvider('sequenceDataProvider')] @@ -453,9 +389,6 @@ static function() { ]; } - /** - * @test - */ #[Test] public function can_use_sequence_with_associative_array(): void { @@ -477,9 +410,6 @@ public function can_use_sequence_with_associative_array(): void ); } - /** - * @test - */ #[Test] public function distribute(): void { @@ -490,9 +420,6 @@ public function distribute(): void self::assertSame('bar', $objects[1]->prop1); } - /** - * @test - */ #[Test] public function distribute_on_factory_collection(): void { @@ -503,9 +430,6 @@ public function distribute_on_factory_collection(): void self::assertSame('bar', $objects[1]->prop1); } - /** - * @test - */ #[Test] public function providing_invalid_values_number_to_distribute_throws(): void { @@ -514,9 +438,6 @@ public function providing_invalid_values_number_to_distribute_throws(): void SimpleObjectFactory::new()->many(2)->distribute('prop1', ['foo']); } - /** - * @test - */ #[Test] public function as_data_provider(): void { diff --git a/tests/Unit/Persistence/PersistentObjectFactoryTest.php b/tests/Unit/Persistence/PersistentObjectFactoryTest.php index 4ab0a1f21..23758c766 100644 --- a/tests/Unit/Persistence/PersistentObjectFactoryTest.php +++ b/tests/Unit/Persistence/PersistentObjectFactoryTest.php @@ -23,9 +23,6 @@ */ final class PersistentObjectFactoryTest extends TestCase { - /** - * @test - */ #[Test] public function can_create(): void { @@ -40,9 +37,6 @@ public function can_create(): void $this->assertSame('value', $entity2->getProp1()); } - /** - * @test - */ #[Test] public function find_or_create(): void { @@ -51,9 +45,6 @@ public function find_or_create(): void $this->assertSame('foo', $entity->getProp1()); } - /** - * @test - */ #[Test] public function random_or_create(): void { @@ -63,8 +54,6 @@ public function random_or_create(): void } /** - * @test - * @dataProvider factoryCollectionDataProvider * @param FactoryCollection $collection */ #[Test] // @phpstan-ignore generics.notSubtype diff --git a/tests/Unit/ReuseEntityTest.php b/tests/Unit/ReuseEntityTest.php index 0f1e59008..ab5ad30dd 100644 --- a/tests/Unit/ReuseEntityTest.php +++ b/tests/Unit/ReuseEntityTest.php @@ -23,9 +23,6 @@ final class ReuseEntityTest extends TestCase { - /** - * @test - */ #[Test] public function it_can_reuse_an_object(): void { @@ -38,9 +35,6 @@ public function it_can_reuse_an_object(): void self::assertSame($address, $contact->getAddress()); } - /** - * @test - */ #[Test] public function last_reused_object_is_used_if_recycling_two_objects_of_same_type(): void { @@ -52,9 +46,6 @@ public function last_reused_object_is_used_if_recycling_two_objects_of_same_type self::assertSame($address, $contact->getAddress()); } - /** - * @test - */ #[Test] public function it_throws_if_recycling_two_objects_of_same_type_with_spread_parameters(): void { @@ -65,9 +56,6 @@ public function it_throws_if_recycling_two_objects_of_same_type_with_spread_para self::assertSame($address, $contact->getAddress()); } - /** - * @test - */ #[Test] public function it_throws_if_recycling_a_factory(): void { @@ -78,9 +66,6 @@ public function it_throws_if_recycling_a_factory(): void ->create(); } - /** - * @test - */ #[Test] public function it_does_nothing_if_reused_object_is_not_used(): void { @@ -91,9 +76,6 @@ public function it_does_nothing_if_reused_object_is_not_used(): void $this->expectNotToPerformAssertions(); } - /** - * @test - */ #[Test] public function it_can_call_reuse_multiple_times(): void { @@ -109,9 +91,6 @@ public function it_can_call_reuse_multiple_times(): void self::assertSame($category, $contact->getCategory()); } - /** - * @test - */ #[Test] public function it_can_call_reuse_multiple_times_with_spread_parameters(): void { @@ -126,9 +105,6 @@ public function it_can_call_reuse_multiple_times_with_spread_parameters(): void self::assertSame($category, $contact->getCategory()); } - /** - * @test - */ #[Test] public function it_reuse_the_same_object_multiple_times(): void { @@ -142,9 +118,6 @@ public function it_reuse_the_same_object_multiple_times(): void self::assertSame($category, $contact->getSecondaryCategory()); } - /** - * @test - */ #[Test] public function it_propagate_reused_objects(): void { @@ -158,9 +131,6 @@ public function it_propagate_reused_objects(): void self::assertSame($category, $address->getContact()->getSecondaryCategory()); } - /** - * @test - */ #[Test] public function reused_object_in_sub_factory_has_priority(): void { @@ -176,9 +146,6 @@ public function reused_object_in_sub_factory_has_priority(): void self::assertSame($category2, $address->getContact()->getSecondaryCategory()); } - /** - * @test - */ #[Test] public function reused_object_dont_have_priority_over_states(): void { @@ -191,9 +158,6 @@ public function reused_object_dont_have_priority_over_states(): void self::assertNotSame($address, $contact->getAddress()); } - /** - * @test - */ #[Test] public function reused_object_on_interface_property(): void { @@ -205,9 +169,6 @@ public function reused_object_on_interface_property(): void self::assertSame($entity, $otherEntity->entity); } - /** - * @test - */ #[Test] public function it_can_reuse_objects_in_collection(): void { @@ -222,9 +183,6 @@ public function it_can_reuse_objects_in_collection(): void self::assertSame($address, $contacts[1]->getAddress()); } - /** - * @test - */ #[Test] public function it_propagates_reused_objects_to_collection(): void { diff --git a/tests/Unit/ZenstruckFoundryBundleTest.php b/tests/Unit/ZenstruckFoundryBundleTest.php index 39d2425f7..23903b5d9 100644 --- a/tests/Unit/ZenstruckFoundryBundleTest.php +++ b/tests/Unit/ZenstruckFoundryBundleTest.php @@ -64,9 +64,6 @@ protected function setUp(): void $this->configurator = new ContainerConfigurator($this->container, $fileLoader, $instanceof, __DIR__, ''); } - /** - * @test - */ #[Test] public function container_has_default_faker_service_definition(): void { @@ -75,9 +72,6 @@ public function container_has_default_faker_service_definition(): void self::assertTrue($this->container->hasDefinition('.zenstruck_foundry.faker')); } - /** - * @test - */ #[Test] public function default_faker_service_can_receive_a_locale_via_configuration(): void { @@ -91,9 +85,6 @@ public function default_faker_service_can_receive_a_locale_via_configuration(): self::assertSame($expected, $definition->getArgument(0)); } - /** - * @test - */ #[Test] public function faker_service_can_be_overridden_with_configuration(): void { @@ -106,9 +97,6 @@ public function faker_service_can_be_overridden_with_configuration(): void self::assertSame($expected, $this->container->get('.zenstruck_foundry.faker')::class); } - /** - * @test - */ #[Test] public function container_has_default_instanciator(): void { @@ -119,9 +107,6 @@ public function container_has_default_instanciator(): void self::assertEmpty($this->container->getDefinition('.zenstruck_foundry.instantiator')->getMethodCalls()); } - /** - * @test - */ #[Test] public function service_can_be_overridden_with_configuration(): void { @@ -134,9 +119,6 @@ public function service_can_be_overridden_with_configuration(): void self::assertSame($expected, $this->container->get('.zenstruck_foundry.instantiator')::class); } - /** - * @test - */ #[Test] public function create_instantiator_without_constructor_configuration(): void { @@ -150,9 +132,6 @@ public function create_instantiator_without_constructor_configuration(): void self::assertSame([], $this->container->getDefinition('.zenstruck_foundry.instantiator')->getMethodCalls()); } - /** - * @test - */ #[Test] public function create_instantiator_without_constructor_and_with_extra_configuration(): void { @@ -166,9 +145,6 @@ public function create_instantiator_without_constructor_and_with_extra_configura self::assertSame([['allowExtra', [], true]], $this->container->getDefinition('.zenstruck_foundry.instantiator')->getMethodCalls()); } - /** - * @test - */ #[Test] public function create_instantiator_without_constructor_and_with_extra_and_with_forced_properties_configuration(): void { @@ -182,9 +158,6 @@ public function create_instantiator_without_constructor_and_with_extra_and_with_ self::assertSame([['allowExtra', [], true], ['alwaysForce', [], true]], $this->container->getDefinition('.zenstruck_foundry.instantiator')->getMethodCalls()); } - /** - * @test - */ #[Test] public function can_enable_auto_refresh_with_lazy_objects(): void { @@ -195,9 +168,6 @@ public function can_enable_auto_refresh_with_lazy_objects(): void self::assertTrue($config['enable_auto_refresh_with_lazy_objects']); } - /** - * @test - */ #[Test] public function can_disable_auto_refresh_with_lazy_objects(): void { @@ -208,9 +178,6 @@ public function can_disable_auto_refresh_with_lazy_objects(): void self::assertFalse($config['enable_auto_refresh_with_lazy_objects']); } - /** - * @test - */ #[Test] public function configuration_default_values(): void { diff --git a/tests/WebTestCase/GetWebTestClientWithResetDatabaseAttributeIsNotBrokenTest.php b/tests/WebTestCase/GetWebTestClientWithResetDatabaseAttributeIsNotBrokenTest.php index 784d01351..e520f2f54 100644 --- a/tests/WebTestCase/GetWebTestClientWithResetDatabaseAttributeIsNotBrokenTest.php +++ b/tests/WebTestCase/GetWebTestClientWithResetDatabaseAttributeIsNotBrokenTest.php @@ -13,30 +13,19 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\Attributes\DependsOnClass; -use PHPUnit\Framework\Attributes\RequiresPhpunit; -use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; +use PHPUnit\Framework\Attributes\RequiresEnvironmentVariable; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Zenstruck\Foundry\Attribute\ResetDatabase; -use Zenstruck\Foundry\PHPUnit\FoundryExtension; use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; -use Zenstruck\Foundry\Tests\Integration\RequiresORM; /** * @author Nicolas PHILIPPE - * @requires PHPUnit >=11 */ #[ResetDatabase] -#[RequiresPhpunit('>=11')] -#[RequiresPhpunitExtension(FoundryExtension::class)] +#[RequiresEnvironmentVariable('DATABASE_URL')] final class GetWebTestClientWithResetDatabaseAttributeIsNotBrokenTest extends WebTestCase { - use RequiresORM; - - /** - * @test - * @depends \Zenstruck\Foundry\Tests\WebTestCase\NoResetGetWebTestClientIsNotBrokenTest::class - */ #[Test] #[DependsOnClass(NoResetGetWebTestClientIsNotBrokenTest::class)] public function boots_kernel_and_get_client(): void @@ -48,10 +37,6 @@ public function boots_kernel_and_get_client(): void self::assertResponseIsSuccessful(); } - /** - * @test - * @depends boots_kernel_and_get_client - */ #[Test] #[Depends('boots_kernel_and_get_client')] public function assert_test_starts_with_a_non_booted_kernel(): void diff --git a/tests/WebTestCase/NoResetGetWebTestClientIsNotBrokenTest.php b/tests/WebTestCase/NoResetGetWebTestClientIsNotBrokenTest.php index 0a2aa3f12..c578f1351 100644 --- a/tests/WebTestCase/NoResetGetWebTestClientIsNotBrokenTest.php +++ b/tests/WebTestCase/NoResetGetWebTestClientIsNotBrokenTest.php @@ -17,9 +17,6 @@ final class NoResetGetWebTestClientIsNotBrokenTest extends WebTestCase { - /** - * @test - */ #[Test] public function boots_kernel_and_get_client(): void { @@ -29,10 +26,6 @@ public function boots_kernel_and_get_client(): void self::assertResponseIsSuccessful(); } - /** - * @test - * @depends boots_kernel_and_get_client - */ #[Test] #[Depends('boots_kernel_and_get_client')] public function assert_test_starts_with_a_non_booted_kernel(): void diff --git a/tests/baseline-ignore b/tests/baseline-ignore deleted file mode 100644 index c8e2bd5f6..000000000 --- a/tests/baseline-ignore +++ /dev/null @@ -1,3 +0,0 @@ -%Subscribing to postConnect events is deprecated.% -%The "Zenstruck\\Foundry.*\(\)" method is considered final.% -%The "Zenstruck\\Foundry.*\(\)" method is considered final.%