public function ViewExecutableTest::testAddHandler 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::testAddHandler()
 
@covers ::addHandler
File
- core/
modules/ views/ tests/ src/ Unit/ ViewExecutableTest.php, line 304  - Contains \Drupal\Tests\views\Unit\ViewExecutableTest.
 
Class
- ViewExecutableTest
 - @coversDefaultClass \Drupal\views\ViewExecutable @group views
 
Namespace
Drupal\Tests\views\UnitCode
public function testAddHandler() {
  /** @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();
  $views_data = [];
  $views_data['test_field'] = [
    'field' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'standard',
    ],
    'argument' => [
      'id' => 'standard',
    ],
    'sort' => [
      'id' => 'standard',
    ],
  ];
  $this->viewsData
    ->expects($this
    ->atLeastOnce())
    ->method('get')
    ->with('test_entity')
    ->willReturn($views_data);
  foreach ([
    'field',
    'filter',
    'argument',
    'sort',
  ] as $handler_type) {
    $display
      ->expects($this
      ->atLeastOnce())
      ->method('setOption')
      ->with($this
      ->callback(function ($argument) {
      return $argument;
    }), [
      'test_field' => [
        'id' => 'test_field',
        'table' => 'test_entity',
        'field' => 'test_field',
        'plugin_id' => 'standard',
      ],
    ]);
  }
  foreach ([
    'field',
    'filter',
    'argument',
    'sort',
  ] as $handler_type) {
    $view
      ->addHandler('default', $handler_type, 'test_entity', 'test_field');
  }
}