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
Put into cache using root entity name #8009
Closed
Closed
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a999918
Put into cache using root entity name
goodtravelsoftware-zz 87292e8
Coding standards fixes
goodtravelsoftware-zz 42f20f7
CS fix
peterkeatingie 8120eb3
Fix scrutinizer issues
peterkeatingie c813064
Move method call, fix alignment
goodtravelsoftware-zz f8c1f0a
Add return type
goodtravelsoftware-zz ba0785c
Add space before colon
goodtravelsoftware-zz e520a98
Use property directly. Update test.
peterkeatingie File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
48 changes: 48 additions & 0 deletions
48
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.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,48 @@ | ||||||
<?php | ||||||
|
||||||
declare(strict_types=1); | ||||||
|
||||||
namespace tests\Doctrine\Tests\ORM\Functional\Ticket; | ||||||
|
||||||
use Doctrine\ORM\Cache\Region\DefaultMultiGetRegion; | ||||||
use Doctrine\Tests\Models\Cache\Attraction; | ||||||
use Doctrine\Tests\Models\Cache\Bar; | ||||||
use Doctrine\Tests\ORM\Functional\SecondLevelCacheAbstractTest; | ||||||
|
||||||
class DDC7969Test extends SecondLevelCacheAbstractTest | ||||||
{ | ||||||
public function testChildEntityRetrievedFromCache() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated now. |
||||||
{ | ||||||
$this->loadFixturesCountries(); | ||||||
$this->loadFixturesStates(); | ||||||
$this->loadFixturesCities(); | ||||||
$this->loadFixturesAttractions(); | ||||||
|
||||||
// Entities are already cached due to fixtures - hence flush before testing | ||||||
$region = $this->cache->getEntityCacheRegion(Attraction::class); | ||||||
|
||||||
if ($region instanceof DefaultMultiGetRegion) { | ||||||
$region->getCache()->flushAll(); | ||||||
} | ||||||
|
||||||
/** @var Bar $bar */ | ||||||
$bar = $this->attractions[0]; | ||||||
|
||||||
$repository = $this->_em->getRepository(Bar::class); | ||||||
|
||||||
$this->assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); | ||||||
beberlei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
$repository->findOneBy([ | ||||||
'name' => $bar->getName(), | ||||||
]); | ||||||
|
||||||
$this->assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); | ||||||
|
||||||
$repository->findOneBy([ | ||||||
'name' => $bar->getName(), | ||||||
]); | ||||||
|
||||||
// One hit for entity cache, one hit for query cache | ||||||
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you call
$cm->getMetadataValue('rootEntityName')
inside the loop?Can you please also put the
=
in line? Probably removing spaces of$identifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I called the property of the metadata directly and then changed to the method call in situ, hence remaining inside the loop. I see your point though, no need to call each time. Updated now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the alignment too.