/** * @covers ::getFieldMap */ public function testGetFieldMapFromCache() { $expected = array('test_entity_type' => array('id' => array('type' => 'integer', 'bundles' => array('first_bundle', 'second_bundle')), 'by_bundle' => array('type' => 'string', 'bundles' => array('second_bundle')))); $this->setUpEntityManager(); $this->cache->expects($this->once())->method('get')->with('entity_field_map')->will($this->returnValue((object) array('data' => $expected))); // Call the field map twice to make sure the static cache works. $this->assertEquals($expected, $this->entityManager->getFieldMap()); $this->assertEquals($expected, $this->entityManager->getFieldMap()); }
/** * @covers ::getRouteProviders */ public function testGetRouteProviders() { $apple = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $apple->expects($this->once())->method('getRouteProviderClasses')->willReturn(['default' => 'Drupal\\Tests\\Core\\Entity\\TestRouteProvider']); $this->setUpEntityManager(array('apple' => $apple)); $apple_route_provider = $this->entityManager->getRouteProviders('apple'); $this->assertInstanceOf('Drupal\\Tests\\Core\\Entity\\TestRouteProvider', $apple_route_provider['default']); $this->assertAttributeInstanceOf('Drupal\\Core\\Extension\\ModuleHandlerInterface', 'moduleHandler', $apple_route_provider['default']); $this->assertAttributeInstanceOf('Drupal\\Core\\StringTranslation\\TranslationInterface', 'stringTranslation', $apple_route_provider['default']); }
/** * @covers ::getRouteProviders */ public function testGetRouteProviders() { $apple = $this->prophesize(EntityTypeInterface::class); $apple->getRouteProviderClasses()->willReturn(['default' => TestRouteProvider::class]); $this->setUpEntityManager(array('apple' => $apple)); $apple_route_provider = $this->entityManager->getRouteProviders('apple'); $this->assertInstanceOf(TestRouteProvider::class, $apple_route_provider['default']); $this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_route_provider['default']); $this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_route_provider['default']); }
/** * @covers ::getEntityTypeFromClass() * * @expectedException \Drupal\Core\Entity\Exception\AmbiguousEntityClassException * @expectedExceptionMessage Multiple entity types found for \Drupal\apple\Entity\Apple. */ public function testGetEntityTypeFromClassAmbiguous() { $boskoop = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $boskoop->expects($this->once())->method('getOriginalClass')->will($this->returnValue('\\Drupal\\apple\\Entity\\Apple')); $boskoop->expects($this->once())->method('id')->will($this->returnValue('boskop')); $gala = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $gala->expects($this->once())->method('getOriginalClass')->will($this->returnValue('\\Drupal\\apple\\Entity\\Apple')); $gala->expects($this->once())->method('id')->will($this->returnValue('gala')); $this->setUpEntityManager(array('boskoop' => $boskoop, 'gala' => $gala)); $this->entityManager->getEntityTypeFromClass('\\Drupal\\apple\\Entity\\Apple'); }