Skip to content

Commit f098922

Browse files
committed
display and fix phpunit warnings
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 27317a7 commit f098922

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

lib/Controller/LogController.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ private function checkProxim(
240240
}
241241
}
242242
if ($proxim->getUrlclose() !== '' && str_starts_with($proxim->getUrlclose(), 'http')) {
243+
set_error_handler(
244+
function ($severity, $message, $file, $line) {
245+
throw new Exception($message);
246+
}
247+
);
243248
// GET
244249
if ($proxim->getUrlclosepost() === 0) {
245250
try {
@@ -268,6 +273,7 @@ private function checkProxim(
268273
$this->logger->warning('Error during PhoneTrack proxim POST URL query', ['exception' => $e]);
269274
}
270275
}
276+
restore_error_handler();
271277
}
272278
} elseif ($proxim->getHighlimit() !== 0 && $prevDist <= $proxim->getHighlimit() && $currDist > $proxim->getHighlimit()) {
273279
// devices are now far !
@@ -371,6 +377,11 @@ private function checkProxim(
371377
}
372378
}
373379
if ($proxim->getUrlfar() !== '' && str_starts_with($proxim->getUrlfar(), 'http')) {
380+
set_error_handler(
381+
function ($severity, $message, $file, $line) {
382+
throw new Exception($message);
383+
}
384+
);
374385
// GET
375386
if ($proxim->getUrlfarpost() === 0) {
376387
try {
@@ -399,6 +410,7 @@ private function checkProxim(
399410
$this->logger->warning('Error during PhoneTrack proxim POST URL query', ['exception' => $e]);
400411
}
401412
}
413+
restore_error_handler();
402414
}
403415
}
404416
}
@@ -535,6 +547,11 @@ private function checkGeoGence(
535547
if ($fence->getUrlenter() !== '' && str_starts_with($fence->getUrlenter(), 'http')) {
536548
// GET
537549
$urlenter = str_replace(['%loc'], sprintf('%f:%f', $lat, $lon), $fence->getUrlenter());
550+
set_error_handler(
551+
function ($severity, $message, $file, $line) {
552+
throw new Exception($message);
553+
}
554+
);
538555
if ($fence->getUrlenterpost() === 0) {
539556
try {
540557
$xml = file_get_contents($urlenter);
@@ -562,6 +579,7 @@ private function checkGeoGence(
562579
$this->logger->warning('Error during PhoneTrack geofence POST URL query', ['exception' => $e]);
563580
}
564581
}
582+
restore_error_handler();
565583
}
566584
}
567585
} // previous point in fence
@@ -655,6 +673,11 @@ private function checkGeoGence(
655673
}
656674
}
657675
if ($fence->getUrlleave() !== '' && str_starts_with($fence->getUrlleave(), 'http')) {
676+
set_error_handler(
677+
function ($severity, $message, $file, $line) {
678+
throw new Exception($message);
679+
}
680+
);
658681
// GET
659682
if ($fence->getUrlleavepost() === 0) {
660683
$urlleave = str_replace(['%loc'], sprintf('%f:%f', $lat, $lon), $fence->getUrlleave());
@@ -684,6 +707,7 @@ private function checkGeoGence(
684707
$this->logger->warning('Error during PhoneTrack geofence POST URL query', ['exception' => $e]);
685708
}
686709
}
710+
restore_error_handler();
687711
}
688712
}
689713
}

tests/phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
bootstrap="bootstrap.php"
4+
displayDetailsOnTestsThatTriggerWarnings="true"
45
displayDetailsOnTestsThatTriggerDeprecations="true"
56
displayDetailsOnPhpunitDeprecations="true"
67
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.4/phpunit.xsd"

0 commit comments

Comments
 (0)