Skip to content

Commit

Permalink
Using container to get the database for kernel tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 committed Aug 6, 2024
1 parent 71616c3 commit 3617c0e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions modules/next/tests/modules/next_tests/next_tests.info.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 3617c0e

Please sign in to comment.