From 3617c0e71b1e9a6a59e48bf959e66acb9df56c05 Mon Sep 17 00:00:00 2001 From: Ankit Pathak Date: Tue, 6 Aug 2024 15:53:30 +0530 Subject: [PATCH] Using container to get the database for kernel tests. --- modules/next/tests/modules/next_tests/next_tests.info.yml | 3 +-- modules/next/tests/src/Kernel/Event/EntityActionEventTest.php | 3 +-- .../next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/next/tests/modules/next_tests/next_tests.info.yml b/modules/next/tests/modules/next_tests/next_tests.info.yml index df77f8a2..39395bbc 100644 --- a/modules/next/tests/modules/next_tests/next_tests.info.yml +++ b/modules/next/tests/modules/next_tests/next_tests.info.yml @@ -1,7 +1,6 @@ name: Next.js tests description: Configures testing for Next.js type: module -core_version_requirement: ^10 || ^11 -package: testing +package: Testing dependencies: - next:next diff --git a/modules/next/tests/src/Kernel/Event/EntityActionEventTest.php b/modules/next/tests/src/Kernel/Event/EntityActionEventTest.php index 5a2fad6d..4f4e9905 100644 --- a/modules/next/tests/src/Kernel/Event/EntityActionEventTest.php +++ b/modules/next/tests/src/Kernel/Event/EntityActionEventTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\next\Kernel\Event; -use Drupal\Core\Database\Database; use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; @@ -84,7 +83,7 @@ protected function assertLogMessage(string $action) { '@action' => $action, ]; - $this->assertNotEmpty(Database::getConnection()->select('watchdog', 'w') + $this->assertNotEmpty($this->container->get('database')->select('watchdog', 'w') ->condition('type', 'system') ->condition('message', $message) ->condition('variables', serialize($variables)) diff --git a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php index 48af81fb..f6c10819 100644 --- a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php +++ b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\next\Kernel\Event; -use Drupal\Core\Database\Database; use Drupal\dblog\Controller\DbLogController; use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; @@ -96,7 +95,7 @@ public function testEntityRevalidatedEvents() { * The message to assert in the logs. */ protected function assertLogsContains(string $message) { - $logs = Database::getConnection() + $logs = $this->container->get('database') ->select('watchdog', 'wd') ->fields('wd', ['message', 'variables']) ->condition('type', 'system')