Skip to content

Commit 44c021a

Browse files
committed
bug fix Logger implementation and Installer tests
1 parent 9ed6045 commit 44c021a

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/Installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static function updateLocalCache(Event $event = null)
195195
if (0 === $retVal) {
196196
$logger->info('Pdp local cache successfully updated.');
197197
} else {
198-
$logger->error("The command failed to update Pdp local cache successfully.");
198+
$logger->error('The command failed to update Pdp local cache successfully.');
199199
}
200200
die($retVal);
201201
}

src/Logger.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function log($level, $message, array $context = [])
5959
$replace['{'.$key.'}'] = $val;
6060
}
6161

62-
fwrite(isset(self::ERRORS_LEVELS[$level]) ? $this->error : $this->out, $message.PHP_EOL);
62+
fwrite(
63+
isset(self::ERRORS_LEVELS[$level]) ? $this->error : $this->out,
64+
strtr($message, $replace).PHP_EOL
65+
);
6366
}
6467
}

tests/InstallerTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ public function getContent(string $url): string
6363

6464
public function log($level, $message, array $context = [])
6565
{
66-
$this->data[] = $message;
66+
$replace = [];
67+
foreach ($context as $key => $val) {
68+
$replace['{'.$key.'}'] = $val;
69+
}
70+
71+
$this->data[] = strtr($message, $replace);
6772
}
6873

6974
public function getLogs(string $level = null): array
@@ -106,8 +111,8 @@ public function contextDataProvider(): array
106111
'context' =>[],
107112
'retval' => 0,
108113
'log' => [
109-
'💪 💪 💪 Your Public Suffix List copy is updated. 💪 💪 💪',
110-
'💪 💪 💪 Your IANA Root Zone Database copy is updated. 💪 💪 💪',
114+
'Public Suffix List Cache updated for 1 DAY using '.Manager::PSL_URL,
115+
'IANA Root Zone Database Cache updated for 1 DAY using '.Manager::RZD_URL,
111116
],
112117
],
113118
'refresh psl only' => [
@@ -116,7 +121,7 @@ public function contextDataProvider(): array
116121
],
117122
'retval' => 0,
118123
'log' => [
119-
'💪 💪 💪 Your Public Suffix List copy is updated. 💪 💪 💪',
124+
'Public Suffix List Cache updated for 1 DAY using '.Manager::PSL_URL,
120125
],
121126
],
122127
'refresh tld only' => [
@@ -125,7 +130,7 @@ public function contextDataProvider(): array
125130
],
126131
'retval' => 0,
127132
'log' => [
128-
'💪 💪 💪 Your IANA Root Zone Database copy is updated. 💪 💪 💪',
133+
'IANA Root Zone Database Cache updated for 1 DAY using '.Manager::RZD_URL,
129134
],
130135
],
131136
'refresh psl fails' => [
@@ -135,7 +140,7 @@ public function contextDataProvider(): array
135140
],
136141
'retval' => 1,
137142
'log' => [
138-
'invalid url: http://localhost/',
143+
'Local cache update failed with invalid url: http://localhost/',
139144
],
140145
],
141146
];

0 commit comments

Comments
 (0)