Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tests requiring PHP ≥ 8.1 to their own directory #10683

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<testsuites>
<testsuite name="Doctrine ORM Test Suite">
<directory>./tests/Doctrine/Tests/ORM</directory>
<directory phpVersion="8.1" phpVersionOperator=">=">./tests_php81</directory>
</testsuite>
</testsuites>

Expand Down
51 changes: 0 additions & 51 deletions tests/Doctrine/Tests/Models/GH10132/Complex.php

This file was deleted.

45 changes: 0 additions & 45 deletions tests/Doctrine/Tests/Models/GH10132/ComplexChild.php

This file was deleted.

11 changes: 0 additions & 11 deletions tests/Doctrine/Tests/Models/GH10288/GH10288People.php

This file was deleted.

49 changes: 0 additions & 49 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH10132Test.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,9 +27,6 @@
use function sprintf;
use function uniqid;

/**
* @requires PHP 8.1
*/
class EnumTest extends OrmFunctionalTestCase
{
public function setUp(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,9 +14,6 @@

use function dirname;

/**
* @requires PHP 8.1
*/
class ReadonlyPropertiesTest extends OrmFunctionalTestCase
{
protected function setUp(): void
Expand Down
117 changes: 117 additions & 0 deletions tests_php81/ORM/Functional/Ticket/GH10132Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests_PHP81\ORM\Functional\Ticket;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\Models\Enums\Suit;
use Doctrine\Tests\OrmFunctionalTestCase;

class GH10132Test extends OrmFunctionalTestCase
{
public function setUp(): void
{
parent::setUp();

$this->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 */
Copy link
Member

@greg0ire greg0ire May 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is indeed no import statement for this… why does the test suite pass when run on Github 🤔 ?

EDIT: Github says it ran 3689 tests… locally, I have 3722 tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 I think you need to modify all of these files: https://github.com/doctrine/orm/tree/2.15.x/ci/github/phpunit

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace of this file (can't comment directly on it) is wrong now, right?

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
{
Expand Down Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,9 +12,6 @@
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

/**
* @requires PHP 8.1
*/
class ReflectionReadonlyPropertyTest extends TestCase
{
public function testSecondWriteWithSameValue(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,7 +13,6 @@
/**
* Test the IdentifierFlattener utility class
*
* @requires PHP 8.1
* @covers \Doctrine\ORM\Utility\IdentifierFlattener
*/
class IdentifierFlattenerEnumIdTest extends OrmFunctionalTestCase
Expand Down