Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created July 12, 2016 19:23
Show Gist options
  • Save Majkl578/61731254ea9d36f2f32778d357ff4f5b to your computer and use it in GitHub Desktop.
Save Majkl578/61731254ea9d36f2f32778d357ff4f5b to your computer and use it in GitHub Desktop.
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\ORM\Functional\SecondLevelCacheAbstractTest;
class DDC5808Test extends SecondLevelCacheAbstractTest
{
protected function setUp()
{
parent::setUp();
$this->_em->getCache()->evictEntityRegion(__NAMESPACE__ . '\DDC5808Geoinformation');
$this->_em->getCache()->evictEntityRegion(__NAMESPACE__ . '\DDC5808GeoinformationMetaData');
$this->_em->clear();
}
public function testIssue()
{
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC5808Geoinformation'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC5808GeoinformationMetaData'),
));
$geo = new DDC5808Geoinformation();
$geo->id = 1;
$geoMetadata = new DDC5808GeoinformationMetaData();
$geoMetadata->id = 2;
$geo->metaData = $geoMetadata;
$geoMetadata->geoinformation = $geo;
$this->_em->persist($geo);
$this->_em->persist($geoMetadata);
$this->_em->flush();
$this->_em->clear();
// no cache
$this->_em->find(__NAMESPACE__ . '\\DDC5808Geoinformation', 1);
$this->_em->clear();
// cache
$this->assertInstanceOf(__NAMESPACE__ . '\\DDC5808Geoinformation', $this->_em->find(__NAMESPACE__ . '\\DDC5808Geoinformation', 1));
}
}
/**
* @Entity
* @Table
* @Cache(usage="NONSTRICT_READ_WRITE", region="geoinformation_region")
*/
class DDC5808Geoinformation
{
/**
* @Id
* @Column(type="integer")
*/
public $id;
/**
* @OneToOne(targetEntity="DDC5808GeoinformationMetaData", inversedBy="geoinformation", cascade={"persist"})
* @JoinColumn(name="geoinformation_meta_data_id", referencedColumnName="id")
* @Cache(usage="NONSTRICT_READ_WRITE", region="geoinformation_region")
*/
public $metaData;
}
/**
* @Entity
* @Table
* @Cache(usage="NONSTRICT_READ_WRITE", region="geoinformation_region")
*/
class DDC5808GeoinformationMetaData
{
/**
* @Id
* @Column(type="integer")
*/
public $id;
/**
* @OneToOne(targetEntity="DDC5808Geoinformation", mappedBy="metaData")
*/
public $geoinformation;
/**
* @Column(nullable=true)
*/
public $foo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment