Esempio n. 1
0
 /**
  * Tests that ViewsBlock::getMachineNameSuggestion() produces the right value.
  *
  * @see \Drupal\views\Plugin\Block::getmachineNameSuggestion().
  */
 public function testMachineNameSuggestion()
 {
     $plugin_definition = array('provider' => 'views');
     $plugin_id = 'views_block:test_view_block-block_1';
     $views_block = ViewsBlock::create($this->container, array(), $plugin_id, $plugin_definition);
     $this->assertEqual($views_block->getMachineNameSuggestion(), 'views_block__test_view_block_block_1');
 }
Esempio n. 2
0
 /**
  * Allows to change the display settings right before executing the block.
  *
  * @param \Drupal\views\Plugin\Block\ViewsBlock $block
  *   The block plugin for views displays.
  */
 public function preBlockBuild(ViewsBlock $block)
 {
     $config = $block->getConfiguration();
     if ($config['items_per_page'] !== 'none') {
         $this->view->setItemsPerPage($config['items_per_page']);
     }
 }
Esempio n. 3
0
 /**
  * Tests the build method with a failed execution.
  *
  * @see \Drupal\views\Plugin\block\ViewsBlock::build()
  */
 public function testBuildFailed()
 {
     $output = FALSE;
     $this->executable->expects($this->once())->method('buildRenderable')->with('block_1', [])->willReturn($output);
     $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(array(), $plugin->build());
 }
Esempio n. 4
0
 /**
  * Tests the build method with overriding items per page.
  */
 public function testBuildOverride()
 {
     $this->executable->expects($this->once())->method('setItemsPerPage')->with(5);
     $this->blockPlugin->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('items_per_page' => 5)));
     $this->blockDisplay->preBlockBuild($this->blockPlugin);
 }