function ViewsSqlExceptionTest::testSqlException
Tests for the SQL exception.
File
- 
              core/modules/ views/ tests/ src/ Kernel/ Plugin/ ViewsSqlExceptionTest.php, line 35 
Class
- ViewsSqlExceptionTest
- Tests the views exception handling.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testSqlException() : void {
  $view = Views::getView('test_filter');
  $view->initDisplay();
  // Adding a filter that will result in an invalid query.
  $view->displayHandlers
    ->get('default')
    ->overrideOption('filters', [
    'test_filter' => [
      'id' => 'test_exception_filter',
      'table' => 'views_test_data',
      'field' => 'name',
      'operator' => '=',
      'value' => 'John',
      'group' => 0,
    ],
  ]);
  $this->expectException(DatabaseExceptionWrapper::class);
  $this->expectExceptionMessageMatches('/^Exception in Test filters\\[test_filter\\]:/');
  $this->executeView($view);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
