function DisplayKernelTest::testisIdentifierUnique
Tests the ::isIdentifierUnique method.
File
- 
              core/modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayKernelTest.php, line 121 
Class
- DisplayKernelTest
- Drupal unit tests for the DisplayPluginBase class.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testisIdentifierUnique() {
  $view = Views::getView('test_view');
  $view->initDisplay();
  // Add a handler that doesn't have an Identifier when exposed.
  $sorts = [
    'name' => [
      'id' => 'name',
      'field' => 'name',
      'table' => 'views_test_data',
      'plugin_id' => 'standard',
      'order' => 'asc',
      'expose' => [
        'label' => 'id',
      ],
      'exposed' => TRUE,
    ],
  ];
  // Add a handler that does have an Identifier when exposed.
  $filters = [
    'id' => [
      'field' => 'id',
      'id' => 'id',
      'table' => 'views_test_data',
      'value' => [],
      'plugin_id' => 'numeric',
      'exposed' => TRUE,
      'expose' => [
        'operator_id' => '',
        'label' => 'Id',
        'description' => '',
        'identifier' => 'id',
        'required' => FALSE,
        'remember' => FALSE,
        'multiple' => FALSE,
      ],
    ],
  ];
  $view->display_handler
    ->setOption('sorts', $sorts);
  $view->display_handler
    ->setOption('filters', $filters);
  $view->save();
  $this->assertTrue($view->display_handler
    ->isIdentifierUnique('some_id', 'some_id'));
  $this->assertFalse($view->display_handler
    ->isIdentifierUnique('some_id', 'id'));
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
