function ViewsSqlExceptionTest::testSqlException
Same name in other branches
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest::testSqlException()
- 10 core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest::testSqlException()
- 11.x core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest::testSqlException()
Tests for the SQL exception.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ ViewsSqlExceptionTest.php, line 33
Class
- ViewsSqlExceptionTest
- Tests the views exception handling.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testSqlException() {
$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.