public function ViewExecutableTest::testAttachDisplays in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testAttachDisplays()
@covers ::attachDisplays
File
- core/
modules/ views/ tests/ src/ Unit/ ViewExecutableTest.php, line 386 - Contains \Drupal\Tests\views\Unit\ViewExecutableTest.
Class
- ViewExecutableTest
- @coversDefaultClass \Drupal\views\ViewExecutable @group views
Namespace
Drupal\Tests\views\UnitCode
public function testAttachDisplays() {
/** @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject $view */
/** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit_Framework_MockObject_MockObject $display */
list($view, $display) = $this
->setupBaseViewAndDisplay();
$display
->expects($this
->atLeastOnce())
->method('acceptAttachments')
->willReturn(TRUE);
$display
->expects($this
->atLeastOnce())
->method('getAttachedDisplays')
->willReturn([
'page_1',
]);
$cloned_view = $this
->getMockBuilder('Drupal\\views\\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$this->viewExecutableFactory
->expects($this
->atLeastOnce())
->method('get')
->willReturn($cloned_view);
$page_display = $this
->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$page_display
->expects($this
->atLeastOnce())
->method('isEnabled')
->willReturn(TRUE);
$display_collection = $this
->getMockBuilder('Drupal\\views\\DisplayPluginCollection')
->disableOriginalConstructor()
->getMock();
$display_collection
->expects($this
->atLeastOnce())
->method('get')
->with('page_1')
->willReturn($page_display);
$view->displayHandlers = $display_collection;
// Setup the expectations.
$page_display
->expects($this
->once())
->method('attachTo')
->with($cloned_view, 'default', $view->element);
$view
->attachDisplays();
}