mirror of
https://github.com/doctrine/orm.git
synced 2026-03-30 02:42:18 +02:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc4ddbfb01 | ||
|
|
14499f5021 | ||
|
|
aae43cbb77 | ||
|
|
db6cb8dedc | ||
|
|
5092da074a | ||
|
|
1c6524db55 |
@@ -23,9 +23,6 @@ script:
|
||||
- ENABLE_SECOND_LEVEL_CACHE=0 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml $PHPUNIT_FLAGS
|
||||
- ENABLE_SECOND_LEVEL_CACHE=1 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml --exclude-group performance,non-cacheable,locking_functional
|
||||
|
||||
after_script:
|
||||
- php vendor/bin/coveralls -v
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- php: hhvm
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "~2.3|~3.0",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"satooshi/php-coveralls": "dev-master"
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/yaml": "If you want to use YAML Metadata Mapping Driver"
|
||||
|
||||
@@ -73,7 +73,7 @@ class DefaultEntityHydrator implements EntityHydrator
|
||||
public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity)
|
||||
{
|
||||
$data = $this->uow->getOriginalEntityData($entity);
|
||||
$data = array_merge($data, $key->identifier); // why update has no identifier values ?
|
||||
$data = array_merge($data, $metadata->getIdentifierValues($entity)); // why update has no identifier values ?
|
||||
|
||||
foreach ($metadata->associationMappings as $name => $assoc) {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.5.3';
|
||||
const VERSION = '2.5.4';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
@@ -119,7 +119,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
|
||||
$this->assertArrayHasKey('name', $cache->data);
|
||||
$this->assertArrayHasKey('country', $cache->data);
|
||||
$this->assertEquals(array(
|
||||
'id' => 11,
|
||||
'id' => 12,
|
||||
'name' => 'Bar',
|
||||
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)),
|
||||
), $cache->data);
|
||||
@@ -147,9 +147,39 @@ class DefaultEntityHydratorTest extends OrmTestCase
|
||||
$this->assertArrayHasKey('name', $cache->data);
|
||||
$this->assertArrayHasKey('country', $cache->data);
|
||||
$this->assertEquals(array(
|
||||
'id' => 11,
|
||||
'id' => 12,
|
||||
'name' => 'Bar',
|
||||
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)),
|
||||
), $cache->data);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCacheEntryWithWrongIdentifierType()
|
||||
{
|
||||
$proxy = $this->em->getReference(Country::CLASSNAME, 11);
|
||||
$entity = new State('Bat', $proxy);
|
||||
$uow = $this->em->getUnitOfWork();
|
||||
$entityData = array('id'=> 12, 'name'=>'Bar', 'country' => $proxy);
|
||||
$metadata = $this->em->getClassMetadata(State::CLASSNAME);
|
||||
$key = new EntityCacheKey($metadata->name, array('id'=>'12'));
|
||||
|
||||
$entity->setId(12);
|
||||
|
||||
$uow->registerManaged($entity, array('id'=>12), $entityData);
|
||||
|
||||
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheEntry', $cache);
|
||||
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $cache);
|
||||
|
||||
$this->assertArrayHasKey('id', $cache->data);
|
||||
$this->assertArrayHasKey('name', $cache->data);
|
||||
$this->assertArrayHasKey('country', $cache->data);
|
||||
$this->assertSame($entity->getId(), $cache->data['id']);
|
||||
$this->assertEquals(array(
|
||||
'id' => 12,
|
||||
'name' => 'Bar',
|
||||
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)),
|
||||
), $cache->data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
35
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php
Normal file
35
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\Models\Cache\Country;
|
||||
use Doctrine\Tests\ORM\Functional\SecondLevelCacheAbstractTest;
|
||||
|
||||
class DDC3967Test extends SecondLevelCacheAbstractTest
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->loadFixturesCountries();
|
||||
$this->_em->getCache()->evictEntityRegion(Country::CLASSNAME);
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public function testIdentifierCachedWithProperType()
|
||||
{
|
||||
$country = array_pop($this->countries);
|
||||
$id = $country->getId();
|
||||
|
||||
// First time, loaded from database
|
||||
$this->_em->find(Country::CLASSNAME, "$id");
|
||||
$this->_em->clear();
|
||||
|
||||
// Second time, loaded from cache
|
||||
/** @var Country $country */
|
||||
$country = $this->_em->find(Country::CLASSNAME, "$id");
|
||||
|
||||
// Identifier type should be integer
|
||||
$this->assertSame($country->getId(), $id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user