diff --git a/src/Context/AdminContext.php b/src/Context/AdminContext.php index 15f73ede43..39cae836b5 100644 --- a/src/Context/AdminContext.php +++ b/src/Context/AdminContext.php @@ -65,7 +65,9 @@ public function getRequest(): Request public function getReferrer(): ?string { - return $this->request->query->get(EA::REFERRER); + $referrer = $this->request->query->get(EA::REFERRER); + + return '' !== $referrer ? $referrer : null; } public function getI18n(): I18nDto diff --git a/tests/Context/AdminContextTest.php b/tests/Context/AdminContextTest.php new file mode 100644 index 0000000000..ced9c408d9 --- /dev/null +++ b/tests/Context/AdminContextTest.php @@ -0,0 +1,43 @@ +createMock(Request::class); + $request->query = new InputBag(); + $request->query->set(EA::REFERRER, ''); + + $target = new AdminContext( + $request, + null, + new I18nDto('en', 'ltr', 'en', []), + new CrudControllerRegistry([], [], [], []), + new DashboardDto(), + $this->createMock(DashboardControllerInterface::class), + new AssetsDto(), + null, + null, + null, + $this->createMock(MenuFactoryInterface::class), + TemplateRegistry::new(), + ); + + self::assertNull($target->getReferrer()); + } +}