class ViewsSqlExceptionTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest
- 10 core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest
Tests the views exception handling.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Plugin\ViewsSqlExceptionTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ViewsSqlExceptionTest
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ ViewsSqlExceptionTest.php, line 14
Namespace
Drupal\Tests\views\Kernel\PluginView source
class ViewsSqlExceptionTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_filter',
];
/**
* {@inheritdoc}
*/
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['name']['filter']['id'] = 'test_exception_filter';
return $data;
}
/**
* Tests for the SQL exception.
*/
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.