You are here

public function ViewsBlockTest::testBuild in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php \Drupal\Tests\views\Unit\Plugin\Block\ViewsBlockTest::testBuild()

Tests the build method.

See also

\Drupal\views\Plugin\block\ViewsBlock::build()

File

core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php, line 142
Contains \Drupal\Tests\views\Unit\Plugin\Block\ViewsBlockTest.

Class

ViewsBlockTest
@coversDefaultClass \Drupal\views\Plugin\block\ViewsBlock @group views

Namespace

Drupal\Tests\views\Unit\Plugin\Block

Code

public function testBuild() {
  $output = $this
    ->randomMachineName(100);
  $build = array(
    'view_build' => $output,
    '#view_id' => 'test_view',
    '#view_display_plugin_class' => '\\Drupal\\views\\Plugin\\views\\display\\Block',
    '#view_display_show_admin_links' => FALSE,
    '#view_display_plugin_id' => 'block',
    '#pre_rendered' => TRUE,
  );
  $this->executable
    ->expects($this
    ->once())
    ->method('buildRenderable')
    ->with('block_1', [])
    ->willReturn($build);
  $block_id = 'views_block:test_view-block_1';
  $config = array();
  $definition = array();
  $definition['provider'] = 'views';
  $plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
  $this
    ->assertEquals($build, $plugin
    ->build());
}