1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Cache; |
4
|
|
|
|
5
|
|
|
use Doctrine\Tests\Mocks\CacheEntryMock; |
6
|
|
|
use Doctrine\Tests\Mocks\CacheKeyMock; |
7
|
|
|
use Doctrine\ORM\Cache\Region\DefaultMultiGetRegion; |
8
|
|
|
use Doctrine\ORM\Cache\CollectionCacheEntry; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @author Asmir Mustafic <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class MultiGetRegionTest extends AbstractRegionTest |
14
|
|
|
{ |
15
|
|
|
protected function createRegion() |
16
|
|
|
{ |
17
|
|
|
return new DefaultMultiGetRegion('default.region.test', $this->cache); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function testGetMulti() |
21
|
|
|
{ |
22
|
|
|
$key1 = new CacheKeyMock('key.1'); |
23
|
|
|
$value1 = new CacheEntryMock(['id' => 1, 'name' => 'bar']); |
24
|
|
|
|
25
|
|
|
$key2 = new CacheKeyMock('key.2'); |
26
|
|
|
$value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); |
27
|
|
|
|
28
|
|
|
$this->assertFalse($this->region->contains($key1)); |
29
|
|
|
$this->assertFalse($this->region->contains($key2)); |
30
|
|
|
|
31
|
|
|
$this->region->put($key1, $value1); |
32
|
|
|
$this->region->put($key2, $value2); |
33
|
|
|
|
34
|
|
|
$this->assertTrue($this->region->contains($key1)); |
35
|
|
|
$this->assertTrue($this->region->contains($key2)); |
36
|
|
|
|
37
|
|
|
$actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); |
38
|
|
|
|
39
|
|
|
$this->assertEquals($value1, $actual[0]); |
40
|
|
|
$this->assertEquals($value2, $actual[1]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @test |
45
|
|
|
* @group GH7266 |
46
|
|
|
*/ |
47
|
|
|
public function corruptedDataDoesNotLeakIntoApplication() : void |
48
|
|
|
{ |
49
|
|
|
$key1 = new CacheKeyMock('key.1'); |
50
|
|
|
$this->cache->save($this->region->getName() . '_' . $key1->hash, 'a-very-invalid-value'); |
51
|
|
|
|
52
|
|
|
self::assertTrue($this->region->contains($key1)); |
53
|
|
|
self::assertNull($this->region->getMultiple(new CollectionCacheEntry([$key1]))); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|