File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function externalLog(string $value): void
4242
4343 // make request to admin-suite log api
4444 $ this ->jsonUtil ->getJson (
45- target: $ externalLogUrl . '?name= ' . urlencode ('code-paste: log ' ) . '&message= ' . urlencode ('code-paste: ' . $ value ) . '&level=4 ' ,
45+ target: $ externalLogUrl . '?name= ' . rawurlencode ('code-paste: log ' ) . '&message= ' . rawurlencode ('code-paste: ' . $ value ) . '&level=4 ' ,
4646 apiKey: $ externalLogToken ,
4747 method: 'POST '
4848 );
Original file line number Diff line number Diff line change @@ -68,8 +68,18 @@ public function testSendLogMessageToExternalLogApiWhenExternalLogEnabled(): void
6868 // log message
6969 $ value = 'This is a test log message ' ;
7070
71+ // expect env values to be fetched for url and api key
72+ $ this ->appUtilMock ->expects ($ this ->exactly (2 ))->method ('getEnvValue ' )->willReturnMap ([
73+ ['EXTERNAL_LOG_URL ' , 'https://external-log-service.com/log ' ],
74+ ['EXTERNAL_LOG_API_TOKEN ' , 'test-token ' ]
75+ ]);
76+
7177 // expect json util get json call
72- $ this ->jsonUtilMock ->expects ($ this ->once ())->method ('getJson ' );
78+ $ this ->jsonUtilMock ->expects ($ this ->once ())->method ('getJson ' )->with (
79+ $ this ->equalTo ('https://external-log-service.com/log?name=code-paste%3A%20log&message=code-paste%3A%20This%20is%20a%20test%20log%20message&level=4 ' ),
80+ $ this ->equalTo ('POST ' ),
81+ $ this ->equalTo ('test-token ' )
82+ );
7383
7484 // call tested method
7585 $ this ->logManager ->externalLog ($ value );
You can’t perform that action at this time.
0 commit comments