public function ElementInfoManagerTest::testGetInfoElementPlugin in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php \Drupal\Tests\Core\Render\ElementInfoManagerTest::testGetInfoElementPlugin()
Tests the getInfo() method when render element plugins are used.
@covers ::getInfo @covers ::buildInfo
@dataProvider providerTestGetInfoElementPlugin
File
- core/tests/ Drupal/ Tests/ Core/ Render/ ElementInfoManagerTest.php, line 77 
- Contains \Drupal\Tests\Core\Render\ElementInfoManagerTest.
Class
- ElementInfoManagerTest
- @coversDefaultClass \Drupal\Core\Render\ElementInfoManager @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testGetInfoElementPlugin($plugin_class, $expected_info) {
  $this->moduleHandler
    ->expects($this
    ->once())
    ->method('alter')
    ->with('element_info', $this
    ->anything())
    ->will($this
    ->returnArgument(0));
  $plugin = $this
    ->getMock($plugin_class);
  $plugin
    ->expects($this
    ->once())
    ->method('getInfo')
    ->willReturn(array(
    '#theme' => 'page',
  ));
  $element_info = $this
    ->getMockBuilder('Drupal\\Core\\Render\\ElementInfoManager')
    ->setConstructorArgs(array(
    new \ArrayObject(),
    $this->cache,
    $this->cacheTagsInvalidator,
    $this->moduleHandler,
    $this->themeManager,
  ))
    ->setMethods(array(
    'getDefinitions',
    'createInstance',
  ))
    ->getMock();
  $this->themeManager
    ->expects($this
    ->any())
    ->method('getActiveTheme')
    ->willReturn(new ActiveTheme([
    'name' => 'test',
  ]));
  $element_info
    ->expects($this
    ->once())
    ->method('createInstance')
    ->with('page')
    ->willReturn($plugin);
  $element_info
    ->expects($this
    ->once())
    ->method('getDefinitions')
    ->willReturn(array(
    'page' => array(
      'class' => 'TestElementPlugin',
    ),
  ));
  $this
    ->assertEquals($expected_info, $element_info
    ->getInfo('page'));
}