From 6489401f6e7f9bc60cee68d9f4822807d9dd55c5 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Mon, 19 Feb 2024 18:38:18 -0500 Subject: [PATCH] Update tests to only register either the annotation or attribute driver to avoid unintended overwrites due to namespaces --- tests/Gedmo/Mapping/LoggableORMMappingTest.php | 16 ++++------------ tests/Gedmo/Mapping/ORMMappingTestCase.php | 4 +--- tests/Gedmo/Mapping/SluggableMappingTest.php | 4 +--- .../Gedmo/Mapping/SoftDeleteableMappingTest.php | 4 +--- tests/Gedmo/Mapping/SortableMappingTest.php | 4 +--- tests/Gedmo/Mapping/TimestampableMappingTest.php | 4 +--- tests/Gedmo/Mapping/TranslatableMappingTest.php | 4 +--- tests/Gedmo/Mapping/UploadableMappingTest.php | 4 +--- .../Gedmo/Timestampable/AttributeChangeTest.php | 2 ++ 9 files changed, 13 insertions(+), 33 deletions(-) diff --git a/tests/Gedmo/Mapping/LoggableORMMappingTest.php b/tests/Gedmo/Mapping/LoggableORMMappingTest.php index 07fd5bf87f..f2d07801e2 100644 --- a/tests/Gedmo/Mapping/LoggableORMMappingTest.php +++ b/tests/Gedmo/Mapping/LoggableORMMappingTest.php @@ -59,9 +59,7 @@ public static function dataLoggableObject(): \Generator { if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedLoggable::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedLoggable::class]; } @@ -121,9 +119,7 @@ public static function dataLoggableObjectWithCompositeKey(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedLoggableComposite::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedLoggableComposite::class]; } @@ -166,9 +162,7 @@ public static function dataLoggableObjectWithCompositeKeyAndRelation(): \Generat if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedLoggableCompositeRelation::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedLoggableCompositeRelation::class]; } @@ -214,9 +208,7 @@ public static function dataLoggableObjectWithEmbedded(): \Generator { if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedLoggableWithEmbedded::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedLoggableWithEmbedded::class]; } } diff --git a/tests/Gedmo/Mapping/ORMMappingTestCase.php b/tests/Gedmo/Mapping/ORMMappingTestCase.php index 661e0275b1..e76bd45367 100644 --- a/tests/Gedmo/Mapping/ORMMappingTestCase.php +++ b/tests/Gedmo/Mapping/ORMMappingTestCase.php @@ -76,9 +76,7 @@ final protected function createChainedMappingDriver(): MappingDriverChain if (PHP_VERSION_ID >= 80000) { $chain->addDriver(new AttributeDriver([]), 'Gedmo\Tests\Mapping\Fixture'); - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { $chain->addDriver(new AnnotationDriver(new AnnotationReader()), 'Gedmo\Tests\Mapping\Fixture'); } diff --git a/tests/Gedmo/Mapping/SluggableMappingTest.php b/tests/Gedmo/Mapping/SluggableMappingTest.php index 12ea9576f5..9b9ad8cce6 100644 --- a/tests/Gedmo/Mapping/SluggableMappingTest.php +++ b/tests/Gedmo/Mapping/SluggableMappingTest.php @@ -51,9 +51,7 @@ public static function dataSluggableObject(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedSluggable::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedSluggable::class]; } } diff --git a/tests/Gedmo/Mapping/SoftDeleteableMappingTest.php b/tests/Gedmo/Mapping/SoftDeleteableMappingTest.php index 914e1528c5..0b868de5c2 100644 --- a/tests/Gedmo/Mapping/SoftDeleteableMappingTest.php +++ b/tests/Gedmo/Mapping/SoftDeleteableMappingTest.php @@ -50,9 +50,7 @@ public static function dataSoftDeleteableObject(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedSoftDeleteable::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedSoftDeleteable::class]; } diff --git a/tests/Gedmo/Mapping/SortableMappingTest.php b/tests/Gedmo/Mapping/SortableMappingTest.php index 63a77c792b..f95c8150f9 100644 --- a/tests/Gedmo/Mapping/SortableMappingTest.php +++ b/tests/Gedmo/Mapping/SortableMappingTest.php @@ -49,9 +49,7 @@ public static function dataSortableObject(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedSortable::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedSortable::class]; } diff --git a/tests/Gedmo/Mapping/TimestampableMappingTest.php b/tests/Gedmo/Mapping/TimestampableMappingTest.php index 2922652f35..91c3ec1d89 100644 --- a/tests/Gedmo/Mapping/TimestampableMappingTest.php +++ b/tests/Gedmo/Mapping/TimestampableMappingTest.php @@ -49,9 +49,7 @@ public static function dataTimestampableObject(): \Generator { if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedCategory::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedCategory::class]; } diff --git a/tests/Gedmo/Mapping/TranslatableMappingTest.php b/tests/Gedmo/Mapping/TranslatableMappingTest.php index f63ed3cc88..4edec0a40e 100644 --- a/tests/Gedmo/Mapping/TranslatableMappingTest.php +++ b/tests/Gedmo/Mapping/TranslatableMappingTest.php @@ -51,9 +51,7 @@ public static function dataSortableObject(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedUser::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedUser::class]; } diff --git a/tests/Gedmo/Mapping/UploadableMappingTest.php b/tests/Gedmo/Mapping/UploadableMappingTest.php index fb60c483dd..e76d13a6f0 100644 --- a/tests/Gedmo/Mapping/UploadableMappingTest.php +++ b/tests/Gedmo/Mapping/UploadableMappingTest.php @@ -54,9 +54,7 @@ public static function dataUploadableObject(): \Generator if (PHP_VERSION_ID >= 80000) { yield 'Model with attributes' => [AnnotatedUploadable::class]; - } - - if (class_exists(AnnotationDriver::class)) { + } elseif (class_exists(AnnotationDriver::class)) { yield 'Model with annotations' => [AnnotatedUploadable::class]; } diff --git a/tests/Gedmo/Timestampable/AttributeChangeTest.php b/tests/Gedmo/Timestampable/AttributeChangeTest.php index c2c260d61a..261a2038dd 100644 --- a/tests/Gedmo/Timestampable/AttributeChangeTest.php +++ b/tests/Gedmo/Timestampable/AttributeChangeTest.php @@ -25,6 +25,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) * * @requires PHP >= 8.0 + * + * @todo This test requires {@see ChangeTest} to have been run first to load the {@see TimestampableListenerStub} */ final class AttributeChangeTest extends BaseTestCaseORM {