Unverified Commit a6596677 authored by alexpott's avatar alexpott

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

parent 81543e17
<?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\Core\Database\DatabaseExceptionWrapper;
......@@ -11,23 +11,12 @@
*
* @group views
*/
class ViewsSqlExceptionTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_filter'];
class ViewsSqlExceptionTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->enableViewsTestModule();
}
public static $testViews = ['test_filter'];
/**
* {@inheritdoc}
......@@ -35,12 +24,11 @@ protected function setUp($import_test_views = TRUE) {
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 @@ public function testSqlException() {
],
]);
try {
$this->expectException(DatabaseExceptionWrapper::class);
$this->expectExceptionMessageRegExp('/^Exception in Test filters\[test_filter\]:/');
$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);
}
}
}
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