From b943ad539813c7055ace7ae517fb6d8c467630b6 Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Sat, 6 May 2023 17:10:49 +0200 Subject: [PATCH] =?UTF-8?q?Move=20tests=20requiring=20PHP=20=E2=89=A5=208.?= =?UTF-8?q?1=20to=20their=20own=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +- phpunit.xml.dist | 1 + .../Doctrine/Tests/Models/GH10132/Complex.php | 51 -------- .../Tests/Models/GH10132/ComplexChild.php | 45 ------- .../Tests/Models/GH10288/GH10288People.php | 11 -- .../ORM/Functional/Ticket/GH10132Test.php | 49 -------- .../ORM/Functional/EnumTest.php | 5 +- .../ORM/Functional/ReadonlyPropertiesTest.php | 5 +- .../ORM/Functional/Ticket/GH10132Test.php | 117 ++++++++++++++++++ .../ORM/Functional/Ticket/GH10288Test.php | 9 +- .../ReflectionReadonlyPropertyTest.php | 5 +- .../Utility/IdentifierFlattenerEnumIdTest.php | 3 +- 12 files changed, 130 insertions(+), 174 deletions(-) delete mode 100644 tests/Doctrine/Tests/Models/GH10132/Complex.php delete mode 100644 tests/Doctrine/Tests/Models/GH10132/ComplexChild.php delete mode 100644 tests/Doctrine/Tests/Models/GH10288/GH10288People.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/GH10132Test.php rename {tests/Doctrine/Tests => tests_php81}/ORM/Functional/EnumTest.php (99%) rename {tests/Doctrine/Tests => tests_php81}/ORM/Functional/ReadonlyPropertiesTest.php (98%) create mode 100644 tests_php81/ORM/Functional/Ticket/GH10132Test.php rename {tests/Doctrine/Tests => tests_php81}/ORM/Functional/Ticket/GH10288Test.php (98%) rename {tests/Doctrine/Tests => tests_php81}/ORM/Mapping/ReflectionReadonlyPropertyTest.php (96%) rename {tests/Doctrine/Tests => tests_php81}/ORM/Utility/IdentifierFlattenerEnumIdTest.php (98%) diff --git a/composer.json b/composer.json index f8a72fc661e..3b98bb42139 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,8 @@ "psr-4": { "Doctrine\\Tests\\": "tests/Doctrine/Tests", "Doctrine\\StaticAnalysis\\": "tests/Doctrine/StaticAnalysis", - "Doctrine\\Performance\\": "tests/Doctrine/Performance" + "Doctrine\\Performance\\": "tests/Doctrine/Performance", + "Doctrine\\Tests_PHP81\\": "tests_php81" } }, "bin": ["bin/doctrine"], diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ab844d2480a..f9d76f05258 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,6 +22,7 @@ ./tests/Doctrine/Tests/ORM + ./tests_php81 diff --git a/tests/Doctrine/Tests/Models/GH10132/Complex.php b/tests/Doctrine/Tests/Models/GH10132/Complex.php deleted file mode 100644 index 816a97dae3e..00000000000 --- a/tests/Doctrine/Tests/Models/GH10132/Complex.php +++ /dev/null @@ -1,51 +0,0 @@ -complexChildren = new ArrayCollection(); - } - - public function getType(): Suit - { - return $this->type; - } - - public function setType(Suit $type): void - { - $this->type = $type; - } - - public function getComplexChildren(): Collection - { - return $this->complexChildren; - } - - public function addComplexChild(ComplexChild $complexChild): void - { - $this->complexChildren->add($complexChild); - } -} diff --git a/tests/Doctrine/Tests/Models/GH10132/ComplexChild.php b/tests/Doctrine/Tests/Models/GH10132/ComplexChild.php deleted file mode 100644 index 393ff8b13ad..00000000000 --- a/tests/Doctrine/Tests/Models/GH10132/ComplexChild.php +++ /dev/null @@ -1,45 +0,0 @@ -addComplexChild($this); - $this->complexType = $complex->getType(); - $this->complex = $complex; - } - - public function getComplexType(): Suit - { - return $this->complexType; - } - - public function getComplex(): Complex - { - return $this->complex; - } -} diff --git a/tests/Doctrine/Tests/Models/GH10288/GH10288People.php b/tests/Doctrine/Tests/Models/GH10288/GH10288People.php deleted file mode 100644 index c5d8c4e8454..00000000000 --- a/tests/Doctrine/Tests/Models/GH10288/GH10288People.php +++ /dev/null @@ -1,11 +0,0 @@ -createSchemaForModels( - Complex::class, - ComplexChild::class - ); - } - - public function testQueryBackedEnumInCompositeKeyJoin(): void - { - $complex = new Complex(); - $complex->setType(Suit::Clubs); - - $complexChild = new ComplexChild(); - $complexChild->setComplex($complex); - - $this->_em->persist($complex); - $this->_em->persist($complexChild); - $this->_em->flush(); - $this->_em->clear(); - - $qb = $this->_em->createQueryBuilder(); - $qb->select('s') - ->from(ComplexChild::class, 's') - ->where('s.complexType = :complexType'); - - $qb->setParameter('complexType', Suit::Clubs); - - self::assertNotNull($qb->getQuery()->getOneOrNullResult()); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests_php81/ORM/Functional/EnumTest.php similarity index 99% rename from tests/Doctrine/Tests/ORM/Functional/EnumTest.php rename to tests_php81/ORM/Functional/EnumTest.php index 3da2ea5f4ff..270bda71c23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests_php81/ORM/Functional/EnumTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Doctrine\Tests\ORM\Functional; +namespace Doctrine\Tests_PHP81\ORM\Functional; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Mapping\Column; @@ -27,9 +27,6 @@ use function sprintf; use function uniqid; -/** - * @requires PHP 8.1 - */ class EnumTest extends OrmFunctionalTestCase { public function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests_php81/ORM/Functional/ReadonlyPropertiesTest.php similarity index 98% rename from tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php rename to tests_php81/ORM/Functional/ReadonlyPropertiesTest.php index 17aa2306df6..5e5844b9010 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests_php81/ORM/Functional/ReadonlyPropertiesTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Doctrine\Tests\ORM\Functional; +namespace Doctrine\Tests_PHP81\ORM\Functional; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Tools\SchemaTool; @@ -14,9 +14,6 @@ use function dirname; -/** - * @requires PHP 8.1 - */ class ReadonlyPropertiesTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests_php81/ORM/Functional/Ticket/GH10132Test.php b/tests_php81/ORM/Functional/Ticket/GH10132Test.php new file mode 100644 index 00000000000..c272a02f154 --- /dev/null +++ b/tests_php81/ORM/Functional/Ticket/GH10132Test.php @@ -0,0 +1,117 @@ +createSchemaForModels( + Complex::class, + ComplexChild::class + ); + } + + public function testQueryBackedEnumInCompositeKeyJoin(): void + { + $complex = new Complex(); + $complex->setType(Suit::Clubs); + + $complexChild = new ComplexChild(); + $complexChild->setComplex($complex); + + $this->_em->persist($complex); + $this->_em->persist($complexChild); + $this->_em->flush(); + $this->_em->clear(); + + $qb = $this->_em->createQueryBuilder(); + $qb->select('s') + ->from(ComplexChild::class, 's') + ->where('s.complexType = :complexType'); + + $qb->setParameter('complexType', Suit::Clubs); + + self::assertNotNull($qb->getQuery()->getOneOrNullResult()); + } +} + +/** @Entity */ +class Complex +{ + /** + * @Id + * @Column(type = "string", enumType = Suit::class) + */ + protected Suit $type; + + /** @OneToMany(targetEntity = ComplexChild::class, mappedBy = "complex", cascade = {"persist"}) */ + protected Collection $complexChildren; + + public function __construct() + { + $this->complexChildren = new ArrayCollection(); + } + + public function getType(): Suit + { + return $this->type; + } + + public function setType(Suit $type): void + { + $this->type = $type; + } + + public function getComplexChildren(): Collection + { + return $this->complexChildren; + } + + public function addComplexChild(ComplexChild $complexChild): void + { + $this->complexChildren->add($complexChild); + } +} + +/** @Entity */ +class ComplexChild +{ + /** + * @ManyToOne(targetEntity = Complex::class, inversedBy = "complexChildren") + * @JoinColumn(name = "complexType", referencedColumnName = "type", nullable = false) + */ + protected Complex $complex; + + /** + * @Id + * @Column(type = "string", enumType = Suit::class) + */ + protected Suit $complexType; + + public function setComplex(Complex $complex): void + { + $complex->addComplexChild($this); + $this->complexType = $complex->getType(); + $this->complex = $complex; + } + + public function getComplexType(): Suit + { + return $this->complexType; + } + + public function getComplex(): Complex + { + return $this->complex; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php b/tests_php81/ORM/Functional/Ticket/GH10288Test.php similarity index 98% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php rename to tests_php81/ORM/Functional/Ticket/GH10288Test.php index 66de8d77f2f..e559383b9f8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php +++ b/tests_php81/ORM/Functional/Ticket/GH10288Test.php @@ -15,14 +15,11 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; -use Doctrine\Tests\Models\GH10288\GH10288People; use Doctrine\Tests\OrmFunctionalTestCase; /** * This test makes sure that Discriminator columns can use both custom types using PHP enums as well as * enumType definition of enums. - * - * @requires PHP 8.1 */ class GH10288Test extends OrmFunctionalTestCase { @@ -114,6 +111,12 @@ public function testEnumDiscriminatorWithCustomEnumType(): void } } +enum GH10288People: string +{ + case BOSS = 'boss'; + case EMPLOYEE = 'employee'; +} + class GH10288PeopleType extends StringType { public const NAME = 'GH10288PeopleType'; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php b/tests_php81/ORM/Mapping/ReflectionReadonlyPropertyTest.php similarity index 96% rename from tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php rename to tests_php81/ORM/Mapping/ReflectionReadonlyPropertyTest.php index aa3e77444de..7d28b19f055 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php +++ b/tests_php81/ORM/Mapping/ReflectionReadonlyPropertyTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Doctrine\Tests\ORM\Mapping; +namespace Doctrine\Tests_PHP81\ORM\Mapping; use Doctrine\ORM\Mapping\ReflectionReadonlyProperty; use Doctrine\Tests\Models\CMS\CmsTag; @@ -12,9 +12,6 @@ use PHPUnit\Framework\TestCase; use ReflectionProperty; -/** - * @requires PHP 8.1 - */ class ReflectionReadonlyPropertyTest extends TestCase { public function testSecondWriteWithSameValue(): void diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests_php81/ORM/Utility/IdentifierFlattenerEnumIdTest.php similarity index 98% rename from tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php rename to tests_php81/ORM/Utility/IdentifierFlattenerEnumIdTest.php index 8b893bf06cc..a5e9350e1b0 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests_php81/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Doctrine\Tests\ORM\Utility; +namespace Doctrine\Tests_PHP81\ORM\Utility; use Doctrine\Tests\Models\Enums\Suit; use Doctrine\Tests\Models\Enums\TypedCardEnumCompositeId; @@ -13,7 +13,6 @@ /** * Test the IdentifierFlattener utility class * - * @requires PHP 8.1 * @covers \Doctrine\ORM\Utility\IdentifierFlattener */ class IdentifierFlattenerEnumIdTest extends OrmFunctionalTestCase