Skip to content

Commit b0aa3d5

Browse files
committed
Address 8.1 and 8.2 unit test failures
1 parent 4912416 commit b0aa3d5

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/Test/Unit/App/Logger/Formatter/ErrorFormatterFactoryTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ protected function setUp(): void
4242

4343
public function testCreate()
4444
{
45+
define("ERRORINFO", $this->createMock(ErrorInfo::class));
46+
define("READERINTEFACE", $this->getMockForAbstractClass(ReaderInterface::class));
4547
$this->containerMock->expects($this->exactly(2))
4648
->method('get')
47-
->willReturnCallback(function (...$args) {
49+
// withConsecutive() alternative.
50+
->willReturnCallback(function ($args) {
4851
static $series = [
49-
[[ErrorInfo::class], $this->createMock(ErrorInfo::class)],
50-
[[ReaderInterface::class], $this->getMockForAbstractClass(ReaderInterface::class)],
52+
[ErrorInfo::class, ERRORINFO],
53+
[ReaderInterface::class, READERINTEFACE]
5154
];
52-
5355
[$expectedArgs, $return] = array_shift($series);
5456
$this->assertSame($expectedArgs, $args);
55-
5657
return $return;
5758
});
5859

src/Test/Unit/Step/Deploy/SetCryptKeyTest.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,13 @@ public function testConfigUpdate(): void
8181
$this->loggerMock->expects($this->exactly(2))
8282
->method('info')
8383
// withConsecutive() alternative.
84-
->willReturnCallback(function ($args) {
85-
static $series = [
86-
'Checking existence of encryption key',
87-
sprintf('Setting encryption key from %s', Environment::VARIABLE_CRYPT_KEY)
88-
];
89-
$expectedArgs = array_shift($series);
90-
$this->assertSame($expectedArgs, $args);
91-
});
84+
->with(self::callback(function (string $message) {
85+
static $i = 0;
86+
return match (++$i) {
87+
1 => $message === 'Checking existence of encryption key',
88+
2 => $message === sprintf('Setting encryption key from %s', Environment::VARIABLE_CRYPT_KEY)
89+
};
90+
}));
9291
$this->configWriterMock->expects($this->once())
9392
->method('update')
9493
->with(['crypt' => ['key' => 'TWFnZW50byBSb3g=']]);
@@ -117,14 +116,13 @@ public function testConfigUpdateWithError(): void
117116
$this->loggerMock->expects($this->exactly(2))
118117
->method('info')
119118
// withConsecutive() alternative.
120-
->willReturnCallback(function ($args) {
121-
static $series = [
122-
'Checking existence of encryption key',
123-
sprintf('Setting encryption key from %s', Environment::VARIABLE_CRYPT_KEY)
124-
];
125-
$expectedArgs = array_shift($series);
126-
$this->assertSame($expectedArgs, $args);
127-
});
119+
->with(self::callback(function (string $message) {
120+
static $i = 0;
121+
return match (++$i) {
122+
1 => $message === 'Checking existence of encryption key',
123+
2 => $message === sprintf('Setting encryption key from %s', Environment::VARIABLE_CRYPT_KEY),
124+
};
125+
}));
128126
$this->configWriterMock->expects($this->once())
129127
->method('update')
130128
->with(['crypt' => ['key' => 'TWFnZW50byBSb3g=']])

0 commit comments

Comments
 (0)