public function EntityTest::testRenderWithIdAndToken in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::testRenderWithIdAndToken()
@covers ::render @covers ::defineOptions @covers ::init
@dataProvider providerTestTokens
File
- core/modules/ views/ tests/ src/ Unit/ Plugin/ area/ EntityTest.php, line 181 
- Contains \Drupal\Tests\views\Unit\Plugin\area\EntityTest.
Class
- EntityTest
- @coversDefaultClass \Drupal\views\Plugin\views\area\Entity @group Entity
Namespace
Drupal\Tests\views\Unit\Plugin\areaCode
public function testRenderWithIdAndToken($token, $id) {
  $this
    ->setupEntityManager();
  $options = [
    'target' => $token,
    'tokenize' => TRUE,
  ];
  $entity = $this
    ->getMock('Drupal\\Core\\Entity\\EntityInterface');
  $entity
    ->expects($this
    ->once())
    ->method('access')
    ->willReturn(TRUE);
  $this->stylePlugin
    ->expects($this
    ->once())
    ->method('tokenizeValue')
    ->with($token, 0)
    ->willReturn($id);
  $this->entityStorage
    ->expects($this
    ->never())
    ->method('loadByProperties');
  $this->entityStorage
    ->expects($this
    ->once())
    ->method('load')
    ->with($id)
    ->willReturn($entity);
  $this->entityViewBuilder
    ->expects($this
    ->once())
    ->method('view')
    ->with($entity, 'default')
    ->willReturn([
    '#markup' => 'hallo',
  ]);
  $this->entityHandler
    ->init($this->executable, $this->display, $options);
  $result = $this->entityHandler
    ->render();
  $this
    ->assertEquals([
    '#markup' => 'hallo',
  ], $result);
}