/** * @covers ::doLoadMultiple * @covers ::buildCacheId * @covers ::getFromPersistentCache */ public function testLoadMultiplePersistentCached() { $this->setUpModuleHandlerNoImplementations(); $key = 'values:' . $this->entityTypeId . ':1'; $id = 1; $entity = $this->getMockBuilder('\\Drupal\\Tests\\Core\\Entity\\ContentEntityDatabaseStorageTestEntityInterface')->getMockForAbstractClass(); $entity->expects($this->any())->method('id')->will($this->returnValue($id)); $this->entityType->expects($this->atLeastOnce())->method('isPersistentlyCacheable')->will($this->returnValue(TRUE)); $this->entityType->expects($this->atLeastOnce())->method('id')->will($this->returnValue($this->entityTypeId)); $this->entityType->expects($this->atLeastOnce())->method('getClass')->will($this->returnValue(get_class($entity))); $this->cache->expects($this->once())->method('getMultiple')->with(array($key))->will($this->returnValue(array($key => (object) array('data' => $entity)))); $this->cache->expects($this->never())->method('set'); $this->setUpEntityStorage(); $entities = $this->entityStorage->loadMultiple(array($id)); $this->assertEquals($entity, $entities[$id]); }