Skip to content

Commit 581e409

Browse files
committed
ISSUE-345: test fix
1 parent 072c18e commit 581e409

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Common/EventListener/ExceptionListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace PhpList\RestBundle\Common\EventListener;
66

77
use Exception;
8+
use PhpList\Core\Domain\Identity\Exception\AdminAttributeCreationException;
89
use PhpList\Core\Domain\Subscription\Exception\SubscriptionCreationException;
910
use Symfony\Component\HttpFoundation\JsonResponse;
1011
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
@@ -35,6 +36,11 @@ public function onKernelException(ExceptionEvent $event): void
3536
'message' => $exception->getMessage(),
3637
], $exception->getStatusCode());
3738
$event->setResponse($response);
39+
} elseif ($exception instanceof AdminAttributeCreationException) {
40+
$response = new JsonResponse([
41+
'message' => $exception->getMessage(),
42+
], $exception->getStatusCode());
43+
$event->setResponse($response);
3844
} elseif ($exception instanceof ValidatorException) {
3945
$response = new JsonResponse([
4046
'message' => $exception->getMessage(),

tests/Integration/Statistics/Controller/AnalyticsControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public function testGetViewOpensStatisticsReturnsViewData(): void
8181
$response = $this->getDecodedJsonResponseContent();
8282

8383
self::assertIsArray($response);
84-
self::assertArrayHasKey('campaigns', $response);
85-
self::assertArrayHasKey('total', $response);
86-
self::assertArrayHasKey('hasMore', $response);
87-
self::assertArrayHasKey('lastId', $response);
84+
self::assertArrayHasKey('items', $response);
85+
self::assertArrayHasKey('pagination', $response);
86+
self::assertIsArray($response['items']);
87+
self::assertIsArray($response['pagination']);
8888
}
8989

9090
public function testGetTopDomainsWithoutSessionKeyReturnsForbidden(): void

0 commit comments

Comments
 (0)