@@ 279-316 (lines=38) @@ | ||
276 | $this->assertCount(13, $this->region->calls['put']); |
|
277 | } |
|
278 | ||
279 | public function testGetBasicQueryResult() |
|
280 | { |
|
281 | $rsm = new ResultSetMappingBuilder($this->em); |
|
282 | $key = new QueryCacheKey('query.key1', 0); |
|
283 | $entry = new QueryCacheEntry( |
|
284 | [ |
|
285 | ['identifier' => ['id' => 1]], |
|
286 | ['identifier' => ['id' => 2]] |
|
287 | ] |
|
288 | ); |
|
289 | ||
290 | $data = [ |
|
291 | ['id'=>1, 'name' => 'Foo'], |
|
292 | ['id'=>2, 'name' => 'Bar'] |
|
293 | ]; |
|
294 | ||
295 | $this->region->addReturn('get', $entry); |
|
296 | ||
297 | $this->region->addReturn( |
|
298 | 'getMultiple', |
|
299 | [ |
|
300 | new EntityCacheEntry(Country::class, $data[0]), |
|
301 | new EntityCacheEntry(Country::class, $data[1]) |
|
302 | ] |
|
303 | ); |
|
304 | ||
305 | $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); |
|
306 | ||
307 | $result = $this->queryCache->get($key, $rsm); |
|
308 | ||
309 | $this->assertCount(2, $result); |
|
310 | $this->assertInstanceOf(Country::class, $result[0]); |
|
311 | $this->assertInstanceOf(Country::class, $result[1]); |
|
312 | $this->assertEquals(1, $result[0]->getId()); |
|
313 | $this->assertEquals(2, $result[1]->getId()); |
|
314 | $this->assertEquals('Foo', $result[0]->getName()); |
|
315 | $this->assertEquals('Bar', $result[1]->getName()); |
|
316 | } |
|
317 | ||
318 | public function testGetWithAssociation() |
|
319 | { |
|
@@ 318-355 (lines=38) @@ | ||
315 | $this->assertEquals('Bar', $result[1]->getName()); |
|
316 | } |
|
317 | ||
318 | public function testGetWithAssociation() |
|
319 | { |
|
320 | $rsm = new ResultSetMappingBuilder($this->em); |
|
321 | $key = new QueryCacheKey('query.key1', 0); |
|
322 | $entry = new QueryCacheEntry( |
|
323 | [ |
|
324 | ['identifier' => ['id' => 1]], |
|
325 | ['identifier' => ['id' => 2]] |
|
326 | ] |
|
327 | ); |
|
328 | ||
329 | $data = [ |
|
330 | ['id'=>1, 'name' => 'Foo'], |
|
331 | ['id'=>2, 'name' => 'Bar'] |
|
332 | ]; |
|
333 | ||
334 | $this->region->addReturn('get', $entry); |
|
335 | ||
336 | $this->region->addReturn( |
|
337 | 'getMultiple', |
|
338 | [ |
|
339 | new EntityCacheEntry(Country::class, $data[0]), |
|
340 | new EntityCacheEntry(Country::class, $data[1]) |
|
341 | ] |
|
342 | ); |
|
343 | ||
344 | $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); |
|
345 | ||
346 | $result = $this->queryCache->get($key, $rsm); |
|
347 | ||
348 | $this->assertCount(2, $result); |
|
349 | $this->assertInstanceOf(Country::class, $result[0]); |
|
350 | $this->assertInstanceOf(Country::class, $result[1]); |
|
351 | $this->assertEquals(1, $result[0]->getId()); |
|
352 | $this->assertEquals(2, $result[1]->getId()); |
|
353 | $this->assertEquals('Foo', $result[0]->getName()); |
|
354 | $this->assertEquals('Bar', $result[1]->getName()); |
|
355 | } |
|
356 | ||
357 | public function testCancelPutResultIfEntityPutFails() |
|
358 | { |