diff --git a/core/modules/views/tests/src/Functional/Plugin/ViewsSqlExceptionTest.php b/core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php similarity index 56% rename from core/modules/views/tests/src/Functional/Plugin/ViewsSqlExceptionTest.php rename to core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php index 40405ae03de0..39574d65f0fa 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ViewsSqlExceptionTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/ViewsSqlExceptionTest.php @@ -1,8 +1,8 @@ enableViewsTestModule(); - } + public static $testViews = ['test_filter']; /** * {@inheritdoc} @@ -35,12 +24,11 @@ class ViewsSqlExceptionTest extends ViewTestBase { protected function viewsData() { $data = parent::viewsData(); $data['views_test_data']['name']['filter']['id'] = 'test_exception_filter'; - return $data; } /** - * Test for the SQL exception. + * Tests for the SQL exception. */ public function testSqlException() { $view = Views::getView('test_filter'); @@ -58,14 +46,10 @@ class ViewsSqlExceptionTest extends ViewTestBase { ], ]); - try { - $this->executeView($view); - $this->fail('Expected exception not thrown.'); - } - catch (DatabaseExceptionWrapper $e) { - $exception_assert_message = "Exception in {$view->storage->label()}[{$view->storage->id()}]"; - $this->assertEqual(strstr($e->getMessage(), ':', TRUE), $exception_assert_message); - } + $this->expectException(DatabaseExceptionWrapper::class); + $this->expectExceptionMessageRegExp('/^Exception in Test filters\[test_filter\]:/'); + + $this->executeView($view); } }