Skip to content

Commit 122e29c

Browse files
authored
test(logger): Simplify Drupal 9 + 10 compatibility (#1290)
1 parent 1ea8292 commit 122e29c

File tree

4 files changed

+20
-76
lines changed

4 files changed

+20
-76
lines changed

phpstan.neon

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ parameters:
1616
# Exclude the RouteLoad producer because the redirect module is not D10
1717
# compatible so we are not downloading it.
1818
- src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php
19-
# This file only exists for Drupal 10 compatibility, ignore it for now.
20-
- tests/src/Traits/CompatibleLoggerTrait10.php
2119
ignoreErrors:
2220
# @todo Ignore phpstan-drupal extension's rules for now, activate later.
2321
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'

tests/src/Kernel/Framework/LoggerTest.php

+20-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Drupal\Tests\graphql\Kernel\Framework;
44

5+
use Drupal\Core\Logger\RfcLoggerTrait;
56
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
6-
use Drupal\Tests\graphql\Traits\CompatibleLoggerTrait;
77
use Psr\Log\LoggerInterface;
88

99
/**
@@ -13,7 +13,14 @@
1313
*/
1414
class LoggerTest extends GraphQLTestBase implements LoggerInterface {
1515

16-
use CompatibleLoggerTrait;
16+
use RfcLoggerTrait;
17+
18+
/**
19+
* Loggers calls.
20+
*
21+
* @var array
22+
*/
23+
protected $loggerCalls = [];
1724

1825
/**
1926
* {@inheritdoc}
@@ -43,6 +50,17 @@ protected function setUp(): void {
4350
$this->container->get('logger.factory')->addLogger($this);
4451
}
4552

53+
/**
54+
* {@inheritdoc}
55+
*/
56+
public function log($level, $message, array $context = []): void {
57+
$this->loggerCalls[] = [
58+
'level' => $level,
59+
'message' => $message,
60+
'context' => $context,
61+
];
62+
}
63+
4664
/**
4765
* Test if invariant violation errors are logged.
4866
*/

tests/src/Traits/CompatibleLoggerTrait.php

-39
This file was deleted.

tests/src/Traits/CompatibleLoggerTrait10.php

-33
This file was deleted.

0 commit comments

Comments
 (0)