/** * Tests the getBundleInfo() method. * * @covers ::getBundleInfo * * @dataProvider providerTestGetBundleInfo */ public function testGetBundleInfo($entity_type_id, $expected) { $apple = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $apple->expects($this->once())->method('getLabel')->will($this->returnValue('Apple')); $banana = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface'); $banana->expects($this->once())->method('getLabel')->will($this->returnValue('Banana')); $this->setUpEntityManager(array('apple' => $apple, 'banana' => $banana)); $bundle_info = $this->entityManager->getBundleInfo($entity_type_id); $this->assertSame($expected, $bundle_info); }
/** * Tests the getBundleInfo() method. * * @covers ::getBundleInfo * * @dataProvider providerTestGetBundleInfo */ public function testGetBundleInfo($entity_type_id, $expected) { $this->moduleHandler->invokeAll('entity_bundle_info')->willReturn([]); $this->moduleHandler->alter('entity_bundle_info', Argument::type('array'))->willReturn(NULL); $apple = $this->prophesize(EntityTypeInterface::class); $apple->getLabel()->willReturn('Apple'); $apple->getBundleOf()->willReturn(NULL); $banana = $this->prophesize(EntityTypeInterface::class); $banana->getLabel()->willReturn('Banana'); $banana->getBundleOf()->willReturn(NULL); $this->setUpEntityManager(array('apple' => $apple, 'banana' => $banana)); $bundle_info = $this->entityManager->getBundleInfo($entity_type_id); $this->assertSame($expected, $bundle_info); }