-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6244 from lcobucci/l2c-ensure-root-classname-ever…
…ywhere Make sure we're using the rootEntityName on all places
- Loading branch information
Showing
5 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\StringType; | ||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\ORM\AbstractQuery; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
final class GH5562Test extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
$this->enableSecondLevelCache(); | ||
|
||
parent::setUp(); | ||
|
||
$this->_schemaTool->createSchema( | ||
[ | ||
$this->_em->getClassMetadata(GH5562User::class), | ||
$this->_em->getClassMetadata(GH5562Manager::class), | ||
$this->_em->getClassMetadata(GH5562Merchant::class), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @group 5562 | ||
*/ | ||
public function testCacheShouldBeUpdatedWhenAssociationChanges() | ||
{ | ||
$manager = new GH5562Manager(); | ||
$merchant = new GH5562Merchant(); | ||
|
||
$manager->username = 'username'; | ||
$manager->merchant = $merchant; | ||
$merchant->manager = $manager; | ||
|
||
$merchant->name = 'Merchant'; | ||
|
||
$this->_em->persist($merchant); | ||
$this->_em->persist($manager); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$merchant = $this->_em->find(GH5562Merchant::class, $merchant->id); | ||
|
||
$merchant->name = mt_rand(); | ||
$merchant->manager->username = 'usernameUPDATE'; | ||
|
||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$merchant = $this->_em->find(GH5562Merchant::class, $merchant->id); | ||
|
||
self::assertEquals('usernameUPDATE', $merchant->manager->username); | ||
} | ||
} | ||
|
||
/** | ||
* @Entity | ||
* @Cache(usage="NONSTRICT_READ_WRITE") | ||
*/ | ||
class GH5562Merchant | ||
{ | ||
/** | ||
* @var integer | ||
* | ||
* @Id | ||
* @Column(name="id", type="integer") | ||
* @GeneratedValue(strategy="IDENTITY") | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @var GH5562Manager | ||
* | ||
* @OneToOne(targetEntity=GH5562Manager::class, mappedBy="merchant") | ||
* @Cache(usage="NONSTRICT_READ_WRITE") | ||
*/ | ||
public $manager; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @Column(name="name", type="string", length=255, nullable=false) | ||
*/ | ||
public $name; | ||
} | ||
|
||
/** | ||
* @Entity | ||
* @InheritanceType("SINGLE_TABLE") | ||
* @DiscriminatorMap({"MANAGER" = GH5562Manager::class}) | ||
*/ | ||
abstract class GH5562User | ||
{ | ||
/** | ||
* @var integer | ||
* | ||
* @Id | ||
* @Column(name="id", type="integer") | ||
* @GeneratedValue(strategy="IDENTITY") | ||
*/ | ||
public $id; | ||
} | ||
|
||
/** | ||
* @Entity | ||
* @Cache(usage="NONSTRICT_READ_WRITE") | ||
*/ | ||
class GH5562Manager extends GH5562User | ||
{ | ||
|
||
/** | ||
* @var string | ||
* | ||
* @Column | ||
*/ | ||
public $username; | ||
|
||
/** | ||
* @var GH5562Merchant | ||
* | ||
* @OneToOne(targetEntity=GH5562Merchant::class, inversedBy="manager") | ||
*/ | ||
public $merchant; | ||
} |