Skip to content

Commit 3cf4028

Browse files
committed
Merge remote-tracking branch 'origin/AC-12022' into Hammer-Plateform-Health-17July24
2 parents acd4f24 + 5f67a46 commit 3cf4028

File tree

12 files changed

+105
-90
lines changed

12 files changed

+105
-90
lines changed

app/code/Magento/Developer/Model/Logger/Handler/Debug.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Exception\RuntimeException;
1616
use Magento\Framework\Filesystem\DriverInterface;
1717
use Magento\Framework\Logger\Handler\Debug as DebugHandler;
18+
use Monolog\LogRecord;
1819

1920
/**
2021
* Enable/disable debug logging based on the store config setting
@@ -53,7 +54,7 @@ public function __construct(
5354
/**
5455
* @inheritdoc
5556
*/
56-
public function isHandling(array $record): bool
57+
public function isHandling(LogRecord $record): bool
5758
{
5859
if ($this->deploymentConfig->isAvailable()) {
5960
return parent::isHandling($record) && $this->isLoggingEnabled();

app/code/Magento/Developer/Model/Logger/Handler/Syslog.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Config\Setup\ConfigOptionsList;
1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212
use Magento\Framework\App\DeploymentConfig;
13+
use Monolog\LogRecord;
1314

1415
/**
1516
* Enable/disable syslog logging based on the deployment config setting.
@@ -22,8 +23,6 @@ class Syslog extends \Magento\Framework\Logger\Handler\Syslog
2223
public const CONFIG_PATH = 'dev/syslog/syslog_logging';
2324

2425
/**
25-
* Deployment config.
26-
*
2726
* @var DeploymentConfig
2827
*/
2928
private $deploymentConfig;
@@ -43,7 +42,7 @@ public function __construct(
4342
/**
4443
* @inheritdoc
4544
*/
46-
public function isHandling(array $record): bool
45+
public function isHandling(LogRecord $record): bool
4746
{
4847
return parent::isHandling($record)
4948
&& $this->deploymentConfig->isDbAvailable()

app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
*/
66
namespace Magento\Developer\Test\Unit\Model\Logger\Handler;
77

8+
use Magento\Config\Setup\ConfigOptionsList;
89
use Magento\Developer\Model\Logger\Handler\Debug;
910
use Magento\Framework\App\Config\ScopeConfigInterface;
1011
use Magento\Framework\App\DeploymentConfig;
1112
use Magento\Framework\App\State;
1213
use Magento\Framework\Filesystem\DriverInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415
use Monolog\Formatter\FormatterInterface;
16+
use Monolog\Level;
1517
use Monolog\Logger;
18+
use Monolog\LogRecord;
1619
use PHPUnit\Framework\MockObject\MockObject;
1720
use PHPUnit\Framework\TestCase;
1821

@@ -51,6 +54,11 @@ class DebugTest extends TestCase
5154
*/
5255
private $deploymentConfigMock;
5356

57+
/**
58+
* @var LogRecord
59+
*/
60+
private $logRecord;
61+
5462
/**
5563
* @inheritdoc
5664
*/
@@ -81,6 +89,13 @@ protected function setUp(): void
8189
'deploymentConfig' => $this->deploymentConfigMock
8290
]);
8391
$this->model->setFormatter($this->formatterMock);
92+
93+
$this->logRecord = new LogRecord(
94+
new \DateTimeImmutable(),
95+
'testChannel',
96+
Level::Debug,
97+
'testMessage'
98+
);
8499
}
85100

86101
/**
@@ -99,7 +114,7 @@ public function testHandleEnabledInDeveloperMode()
99114
->expects($this->never())
100115
->method('getValue');
101116

102-
$this->assertTrue($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG]));
117+
$this->assertTrue($this->model->isHandling($this->logRecord));
103118
}
104119

105120
/**
@@ -118,7 +133,7 @@ public function testHandleEnabledInDefaultMode()
118133
->expects($this->never())
119134
->method('getValue');
120135

121-
$this->assertTrue($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG]));
136+
$this->assertTrue($this->model->isHandling($this->logRecord));
122137
}
123138

124139
/**
@@ -137,7 +152,7 @@ public function testHandleDisabledByProduction()
137152
->expects($this->never())
138153
->method('getValue');
139154

140-
$this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG]));
155+
$this->assertFalse($this->model->isHandling($this->logRecord));
141156
}
142157

143158
/**
@@ -148,15 +163,19 @@ public function testHandleDisabledByLevel()
148163
$this->deploymentConfigMock->expects($this->once())
149164
->method('isAvailable')
150165
->willReturn(true);
151-
$this->stateMock
152-
->expects($this->never())
153-
->method('getMode')
154-
->willReturn(State::MODE_DEVELOPER);
155-
$this->scopeConfigMock
156-
->expects($this->never())
157-
->method('getValue');
166+
$this->deploymentConfigMock->expects($this->once())
167+
->method('get')
168+
->with(ConfigOptionsList::CONFIG_PATH_DEBUG_LOGGING)
169+
->willReturn(false);
158170

159-
$this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::API]));
171+
$this->assertFalse($this->model->isHandling(
172+
new LogRecord(
173+
new \DateTimeImmutable(),
174+
'testChannel',
175+
Level::Error,
176+
'testMessage'
177+
)
178+
));
160179
}
161180

162181
/**
@@ -174,6 +193,6 @@ public function testDeploymentConfigIsNotAvailable()
174193
->expects($this->never())
175194
->method('getValue');
176195

177-
$this->assertTrue($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG]));
196+
$this->assertTrue($this->model->isHandling($this->logRecord));
178197
}
179198
}

app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/SyslogTest.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Framework\App\Config\ScopeConfigInterface;
1313
use Magento\Framework\App\DeploymentConfig;
1414
use Magento\Framework\Logger\Monolog;
15+
use Monolog\Handler\AbstractHandler;
16+
use Monolog\Level;
17+
use Monolog\LogRecord;
1518
use PHPUnit\Framework\MockObject\MockObject as Mock;
1619
use PHPUnit\Framework\TestCase;
1720

@@ -35,13 +38,24 @@ class SyslogTest extends TestCase
3538
*/
3639
private $deploymentConfigMock;
3740

41+
/**
42+
* @var LogRecord
43+
*/
44+
private $logRecord;
45+
3846
/**
3947
* @inheritdoc
4048
*/
4149
protected function setUp(): void
4250
{
4351
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
4452
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
53+
$this->logRecord = new LogRecord(
54+
new \DateTimeImmutable(),
55+
'testChannel',
56+
Level::Debug,
57+
'testMessage'
58+
);
4559

4660
$this->model = new Syslog(
4761
$this->deploymentConfigMock,
@@ -54,10 +68,6 @@ protected function setUp(): void
5468
*/
5569
public function testIsHandling(): void
5670
{
57-
$record = [
58-
'level' => Monolog::DEBUG,
59-
];
60-
6171
$this->scopeConfigMock
6272
->expects($this->never())
6373
->method('getValue');
@@ -72,7 +82,7 @@ public function testIsHandling(): void
7282
->willReturn(1);
7383

7484
$this->assertTrue(
75-
$this->model->isHandling($record)
85+
$this->model->isHandling($this->logRecord)
7686
);
7787
}
7888

@@ -81,10 +91,6 @@ public function testIsHandling(): void
8191
*/
8292
public function testIsHandlingNotInstalled(): void
8393
{
84-
$record = [
85-
'level' => Monolog::DEBUG,
86-
];
87-
8894
$this->scopeConfigMock
8995
->expects($this->never())
9096
->method('getValue');
@@ -94,7 +100,7 @@ public function testIsHandlingNotInstalled(): void
94100
->willReturn(false);
95101

96102
$this->assertFalse(
97-
$this->model->isHandling($record)
103+
$this->model->isHandling($this->logRecord)
98104
);
99105
}
100106

@@ -103,10 +109,6 @@ public function testIsHandlingNotInstalled(): void
103109
*/
104110
public function testIsHandlingDisabled(): void
105111
{
106-
$record = [
107-
'level' => Monolog::DEBUG,
108-
];
109-
110112
$this->scopeConfigMock
111113
->expects($this->never())
112114
->method('getValue');
@@ -121,7 +123,7 @@ public function testIsHandlingDisabled(): void
121123
->willReturn(0);
122124

123125
$this->assertFalse(
124-
$this->model->isHandling($record)
126+
$this->model->isHandling($this->logRecord)
125127
);
126128
}
127129
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"magento/zend-cache": "^1.16",
7575
"magento/zend-db": "^1.16",
7676
"magento/zend-pdf": "^1.16",
77-
"monolog/monolog": "^2.7",
77+
"monolog/monolog": "^3.6",
7878
"opensearch-project/opensearch-php": "^1.0 || ^2.0",
7979
"pelago/emogrifier": "^7.0",
8080
"php-amqplib/php-amqplib": "^3.2",

composer.lock

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Logger.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Logger\Monolog;
1111
use Monolog\Handler\HandlerInterface;
1212
use Monolog\DateTimeImmutable;
13+
use Monolog\Level;
1314

1415
class Logger extends Monolog
1516
{
@@ -66,17 +67,17 @@ public function getMessages(): array
6667
/**
6768
* @inheritdoc
6869
*
69-
* @param int $level The logging level
70+
* @param int|Level $level The logging level
7071
* @param string $message The log message
7172
* @param array $context The log context
72-
* @param DateTimeImmutable $datetime Optional log date to log into the past or future
73+
* @param DateTimeImmutable|null $datetime Optional log date to log into the past or future
7374
* @return bool Whether the record has been processed
7475
*/
7576
public function addRecord(
76-
int $level,
77+
int|Level $level,
7778
string $message,
7879
array $context = [],
79-
DateTimeImmutable $datetime = null
80+
DateTimeImmutable|null $datetime = null
8081
): bool {
8182
if ($level <= $this->minimumErrorLevel) {
8283
$this->messages[] = [

dev/tests/integration/testsuite/Magento/GraphQlResolverCache/Model/Resolver/Result/HydratorDehydratorProviderTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ public function testHydratorClassMismatch()
187187
. 'Magento\GraphQlResolverCache\Model\Resolver\Result\HydratorInterface.');
188188
$testModelDehydrator = $this->getMockBuilder(DehydratorInterface::class)
189189
->disableOriginalConstructor()
190-
->setMockClassName('TestResolverModelDehydrator')
191-
->onlyMethods(['dehydrate'])
192190
->getMock();
193191
$this->objectManager->addSharedInstance($testModelDehydrator, 'TestResolverModelDehydrator');
194192

@@ -223,7 +221,6 @@ public function testDehydratorClassMismatch()
223221
. 'Magento\GraphQlResolverCache\Model\Resolver\Result\DehydratorInterface.');
224222
$hydrator = $this->getMockBuilder(HydratorInterface::class)
225223
->disableOriginalConstructor()
226-
->setMockClassName('TestResolverModelHydrator')
227224
->getMock();
228225
$this->objectManager->addSharedInstance($hydrator, 'TestResolverModelHydrator');
229226

0 commit comments

Comments
 (0)