From eb2baa20ef131f6f0d559f8ed68552e118fccfb8 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Mon, 29 Jan 2024 10:55:54 +0000 Subject: [PATCH] Issue #3041755 by Hardik_Patel_12, claudiu.cristea, Lendude, Spokje, smustgrave, amateescu, alexpott, longwave: Convert HandlerAllTest into a kernel test --- .../Handler/HandlerAllTest.php | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) rename core/modules/views/tests/src/{Functional => Kernel}/Handler/HandlerAllTest.php (66%) diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerAllTest.php b/core/modules/views/tests/src/Kernel/Handler/HandlerAllTest.php similarity index 66% rename from core/modules/views/tests/src/Functional/Handler/HandlerAllTest.php rename to core/modules/views/tests/src/Kernel/Handler/HandlerAllTest.php index 41c40f023e2b..7ec385f5fa77 100644 --- a/core/modules/views/tests/src/Functional/Handler/HandlerAllTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/HandlerAllTest.php @@ -1,9 +1,12 @@ <?php -namespace Drupal\Tests\views\Functional\Handler; +namespace Drupal\Tests\views\Kernel\Handler; +use Drupal\comment\Entity\CommentType; use Drupal\comment\Tests\CommentTestTrait; -use Drupal\Tests\views\Functional\ViewTestBase; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\node\Entity\NodeType; +use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Plugin\views\filter\NumericFilter; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\HandlerBase; @@ -15,28 +18,34 @@ * * @group views */ -class HandlerAllTest extends ViewTestBase { +class HandlerAllTest extends ViewsKernelTestBase { use CommentTestTrait; /** - * Modules to enable. - * - * @var array + * {@inheritdoc} */ protected static $modules = [ 'block', 'comment', 'contact', + 'dblog', 'field', 'filter', 'file', + 'forum', 'history', + 'image', 'language', 'locale', + 'media', 'node', 'search', + 'system', + 'options', 'taxonomy', + 'text', + 'tracker', 'user', ]; @@ -48,8 +57,26 @@ class HandlerAllTest extends ViewTestBase { /** * Tests most of the handlers. */ - public function testHandlers() { - $this->drupalCreateContentType(['type' => 'article']); + public function testHandlers(): void { + $this->installEntitySchema('comment'); + $this->installEntitySchema('file'); + $this->installEntitySchema('media'); + $this->installEntitySchema('node'); + $this->installEntitySchema('taxonomy_term'); + $this->installEntitySchema('user'); + $this->installSchema('file', ['file_usage']); + $this->installSchema('forum', ['forum_index']); + $this->installSchema('dblog', ['watchdog']); + $this->installSchema('tracker', ['tracker_user']); + // Create the comment body field storage. + FieldStorageConfig::create([ + 'type' => 'text_long', + 'entity_type' => 'comment', + 'field_name' => 'comment_body', + ])->save(); + + NodeType::create(['type' => 'article', 'name' => 'Article'])->save(); + CommentType::create(['id' => 'comment', 'label' => 'Default comment', 'target_entity_type_id' => 'node'])->save(); $this->addDefaultCommentField('node', 'article'); $object_types = array_keys(ViewExecutable::getHandlerTypes()); @@ -58,8 +85,8 @@ public function testHandlers() { continue; } - $view = View::create(['base_table' => $base_table]); - $view = $view->getExecutable(); + $view_config = View::create(['base_table' => $base_table]); + $view = $view_config->getExecutable(); // @todo The groupwise relationship is currently broken. $exclude[] = 'taxonomy_term_field_data:tid_representative'; -- GitLab