/** * @covers ::getExtraFields */ function testgetExtraFields() { $this->setUpEntityManager(); $entity_type_id = $this->randomMachineName(); $bundle = $this->randomMachineName(); $language_code = 'en'; $hook_bundle_extra_fields = array($entity_type_id => array($bundle => array('form' => array('foo_extra_field' => array('label' => 'Foo'))))); $processed_hook_bundle_extra_fields = $hook_bundle_extra_fields; $processed_hook_bundle_extra_fields[$entity_type_id][$bundle] += array('display' => array()); $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $language_code; $language = new Language(array('id' => $language_code)); $this->languageManager->expects($this->once())->method('getCurrentLanguage')->will($this->returnValue($language)); $this->cacheBackend->expects($this->once())->method('get')->with($cache_id); $this->moduleHandler->expects($this->once())->method('invokeAll')->with('entity_extra_field_info')->will($this->returnValue($hook_bundle_extra_fields)); $this->moduleHandler->expects($this->once())->method('alter')->with('entity_extra_field_info', $hook_bundle_extra_fields); $this->cacheBackend->expects($this->once())->method('set')->with($cache_id, $processed_hook_bundle_extra_fields[$entity_type_id][$bundle]); $this->assertSame($processed_hook_bundle_extra_fields[$entity_type_id][$bundle], $this->entityManager->getExtraFields($entity_type_id, $bundle)); }
/** * @covers ::getExtraFields */ function testGetExtraFields() { $this->setUpEntityManager(); $entity_type_id = $this->randomMachineName(); $bundle = $this->randomMachineName(); $language_code = 'en'; $hook_bundle_extra_fields = array($entity_type_id => array($bundle => array('form' => array('foo_extra_field' => array('label' => 'Foo'))))); $processed_hook_bundle_extra_fields = $hook_bundle_extra_fields; $processed_hook_bundle_extra_fields[$entity_type_id][$bundle] += array('display' => array()); $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $language_code; $language = new Language(array('id' => $language_code)); $this->languageManager->getCurrentLanguage()->willReturn($language)->shouldBeCalledTimes(1); $this->cacheBackend->get($cache_id)->shouldBeCalled(); $this->moduleHandler->invokeAll('entity_extra_field_info')->willReturn($hook_bundle_extra_fields); $this->moduleHandler->alter('entity_extra_field_info', $hook_bundle_extra_fields)->shouldBeCalled(); $this->cacheBackend->set($cache_id, $processed_hook_bundle_extra_fields[$entity_type_id][$bundle], Cache::PERMANENT, ['entity_field_info'])->shouldBeCalled(); $this->assertSame($processed_hook_bundle_extra_fields[$entity_type_id][$bundle], $this->entityManager->getExtraFields($entity_type_id, $bundle)); }