Skip to content

Commit

Permalink
Improved testing region->getMultiple()
Browse files Browse the repository at this point in the history
  • Loading branch information
holtkamp committed Apr 13, 2015
1 parent 3f84be7 commit 74964e7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
25 changes: 25 additions & 0 deletions tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace Doctrine\Tests\ORM\Cache;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Cache\CollectionCacheEntry;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\Tests\Mocks\CacheEntryMock;
use Doctrine\Tests\Mocks\CacheKeyMock;


/**
* @group DDC-2183
*/
Expand Down Expand Up @@ -72,4 +74,27 @@ public function testEvictAllWithGenericCacheThrowsUnsupportedException()

$region->evictAll();
}

public function testGetMulti()
{
$key1 = new CacheKeyMock('key.1');
$value1 = new CacheEntryMock(array('id' => 1, 'name' => 'bar'));

$key2 = new CacheKeyMock('key.2');
$value2 = new CacheEntryMock(array('id' => 2, 'name' => 'bar'));

$this->assertFalse($this->region->contains($key1));
$this->assertFalse($this->region->contains($key2));

$this->region->put($key1, $value1);
$this->region->put($key2, $value2);

$this->assertTrue($this->region->contains($key1));
$this->assertTrue($this->region->contains($key2));

$actual = $this->region->getMultiple(new CollectionCacheEntry(array($key1, $key2)));

$this->assertEquals($value1, $actual[0]);
$this->assertEquals($value2, $actual[1]);
}
}
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ protected function createRegion()
public function testGetMulti()
{
$key1 = new CacheKeyMock('key.1');
$value1 = new CacheEntryMock(array('id'=>1, 'name' => 'bar'));
$value1 = new CacheEntryMock(array('id' => 1, 'name' => 'bar'));

$key2 = new CacheKeyMock('key.2');
$value2 = new CacheEntryMock(array('id'=>2, 'name' => 'bar'));
$value2 = new CacheEntryMock(array('id' => 2, 'name' => 'bar'));

$this->assertFalse($this->region->contains($key1));
$this->assertFalse($this->region->contains($key2));

$this->region->put($key1, $value1);
$this->region->put($key2, $value2);

$this->assertTrue($this->region->contains($key1));
$this->assertTrue($this->region->contains($key2));

$actual = $this->region->getMultiple(new CollectionCacheEntry(array($key1, $key2)));

$this->assertEquals($value1, $actual[0]);
Expand Down

0 comments on commit 74964e7

Please sign in to comment.