示例#1
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityStorage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $this->entityViewBuilder = $this->getMock('Drupal\\Core\\Entity\\EntityViewBuilderInterface');
     $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->getMock();
     $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
     $this->stylePlugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\style\\StylePluginBase')->disableOriginalConstructor()->getMock();
     $this->executable->style_plugin = $this->stylePlugin;
     $this->entityHandler = new Entity(array(), 'entity', array('entity_type' => 'entity_test'), $this->entityManager);
     $this->display->expects($this->any())->method('getPlugin')->with('style')->willReturn($this->stylePlugin);
     $this->executable->expects($this->any())->method('getStyle')->willReturn($this->stylePlugin);
     $token = $this->getMockBuilder('Drupal\\Core\\Utility\\Token')->disableOriginalConstructor()->getMock();
     $token->expects($this->any())->method('replace')->willReturnArgument(0);
     $container = new ContainerBuilder();
     $container->set('token', $token);
     \Drupal::setContainer($container);
 }
示例#2
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());
 }
示例#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('executeDisplay')->with($this->equalTo('block_1'))->will($this->returnValue($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);
     $reflector = new \ReflectionClass($plugin);
     $property = $reflector->getProperty('conditionPluginManager');
     $property->setAccessible(TRUE);
     $property->setValue($plugin, $this->getMock('Drupal\\Core\\Executable\\ExecutableManagerInterface'));
     $this->assertEquals(array(), $plugin->build());
 }
示例#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);
 }