Unverified Commit a6596677 authored by alexpott's avatar alexpott

Issue #3041790 by claudiu.cristea, Lendude: Convert ViewsSqlExceptionTest to a kernel test

parent 81543e17
<?php <?php
namespace Drupal\Tests\views\Functional\Plugin; namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\Tests\views\Functional\ViewTestBase; use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views; use Drupal\views\Views;
use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\DatabaseExceptionWrapper;
...@@ -11,23 +11,12 @@ ...@@ -11,23 +11,12 @@
* *
* @group views * @group views
*/ */
class ViewsSqlExceptionTest extends ViewTestBase { class ViewsSqlExceptionTest extends ViewsKernelTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_filter'];
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setUp($import_test_views = TRUE) { public static $testViews = ['test_filter'];
parent::setUp($import_test_views);
$this->enableViewsTestModule();
}
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -35,12 +24,11 @@ protected function setUp($import_test_views = TRUE) { ...@@ -35,12 +24,11 @@ protected function setUp($import_test_views = TRUE) {
protected function viewsData() { protected function viewsData() {
$data = parent::viewsData(); $data = parent::viewsData();
$data['views_test_data']['name']['filter']['id'] = 'test_exception_filter'; $data['views_test_data']['name']['filter']['id'] = 'test_exception_filter';
return $data; return $data;
} }
/** /**
* Test for the SQL exception. * Tests for the SQL exception.
*/ */
public function testSqlException() { public function testSqlException() {
$view = Views::getView('test_filter'); $view = Views::getView('test_filter');
...@@ -58,14 +46,10 @@ public function testSqlException() { ...@@ -58,14 +46,10 @@ public function testSqlException() {
], ],
]); ]);
try { $this->expectException(DatabaseExceptionWrapper::class);
$this->executeView($view); $this->expectExceptionMessageRegExp('/^Exception in Test filters\[test_filter\]:/');
$this->fail('Expected exception not thrown.');
} $this->executeView($view);
catch (DatabaseExceptionWrapper $e) {
$exception_assert_message = "Exception in {$view->storage->label()}[{$view->storage->id()}]";
$this->assertEqual(strstr($e->getMessage(), ':', TRUE), $exception_assert_message);
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment