Skip to content

Commit

Permalink
test(logger): Simplify Drupal 9 + 10 compatibility (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi authored Jun 18, 2022
1 parent 1ea8292 commit 122e29c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 76 deletions.
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ parameters:
# Exclude the RouteLoad producer because the redirect module is not D10
# compatible so we are not downloading it.
- src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php
# This file only exists for Drupal 10 compatibility, ignore it for now.
- tests/src/Traits/CompatibleLoggerTrait10.php
ignoreErrors:
# @todo Ignore phpstan-drupal extension's rules for now, activate later.
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
Expand Down
22 changes: 20 additions & 2 deletions tests/src/Kernel/Framework/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Drupal\Tests\graphql\Kernel\Framework;

use Drupal\Core\Logger\RfcLoggerTrait;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
use Drupal\Tests\graphql\Traits\CompatibleLoggerTrait;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -13,7 +13,14 @@
*/
class LoggerTest extends GraphQLTestBase implements LoggerInterface {

use CompatibleLoggerTrait;
use RfcLoggerTrait;

/**
* Loggers calls.
*
* @var array
*/
protected $loggerCalls = [];

/**
* {@inheritdoc}
Expand Down Expand Up @@ -43,6 +50,17 @@ protected function setUp(): void {
$this->container->get('logger.factory')->addLogger($this);
}

/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []): void {
$this->loggerCalls[] = [
'level' => $level,
'message' => $message,
'context' => $context,
];
}

/**
* Test if invariant violation errors are logged.
*/
Expand Down
39 changes: 0 additions & 39 deletions tests/src/Traits/CompatibleLoggerTrait.php

This file was deleted.

33 changes: 0 additions & 33 deletions tests/src/Traits/CompatibleLoggerTrait10.php

This file was deleted.

0 comments on commit 122e29c

Please sign in to comment.