From d992d30cfdf3d72de2a24c656456d6d1c718bf2b Mon Sep 17 00:00:00 2001 From: marcelmanzel Date: Fri, 28 Jun 2024 14:54:55 +0200 Subject: [PATCH] OXDEV-8213: Remove unnecessary default values in ThemeFilters --- src/Theme/Controller/ThemeListController.php | 2 +- src/Theme/DataType/ThemeFilters.php | 4 ++-- src/Theme/DataType/ThemeFiltersInterface.php | 4 ++-- .../Unit/Theme/Controller/ThemeListControllerTest.php | 2 +- tests/Unit/Theme/DataType/ThemeFiltersTest.php | 10 ++++++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Theme/Controller/ThemeListController.php b/src/Theme/Controller/ThemeListController.php index c4c0360..cfe0f0c 100644 --- a/src/Theme/Controller/ThemeListController.php +++ b/src/Theme/Controller/ThemeListController.php @@ -31,7 +31,7 @@ public function __construct( #[Query] #[Logged] #[Right('CHANGE_CONFIGURATION')] - public function themesList(?ThemeFilters $filters = null): array + public function themesList(?ThemeFilters $filters): array { return $this->themeListService->getThemeList($filters ?? new ThemeFilters()); } diff --git a/src/Theme/DataType/ThemeFilters.php b/src/Theme/DataType/ThemeFilters.php index 4757580..c740e08 100644 --- a/src/Theme/DataType/ThemeFilters.php +++ b/src/Theme/DataType/ThemeFilters.php @@ -46,8 +46,8 @@ public function filterThemeByStatus(ThemeDataType $theme): bool * @Factory(name="ThemeFilters", default=true) */ public static function createThemeFilters( - ?StringFilter $title = null, - ?BoolFilter $active = null + ?StringFilter $title, + ?BoolFilter $active ): self { return new self(titleFilter: $title, activeFilter: $active); } diff --git a/src/Theme/DataType/ThemeFiltersInterface.php b/src/Theme/DataType/ThemeFiltersInterface.php index 5f29520..666b6cf 100644 --- a/src/Theme/DataType/ThemeFiltersInterface.php +++ b/src/Theme/DataType/ThemeFiltersInterface.php @@ -15,7 +15,7 @@ interface ThemeFiltersInterface public function filterThemeByTitle(ThemeDataType $theme): bool; public function filterThemeByStatus(ThemeDataType $theme): bool; public static function createThemeFilters( - ?StringFilter $titleFilter = null, - ?BoolFilter $activeFilter = null + ?StringFilter $titleFilter, + ?BoolFilter $activeFilter ): ThemeFilters; } diff --git a/tests/Unit/Theme/Controller/ThemeListControllerTest.php b/tests/Unit/Theme/Controller/ThemeListControllerTest.php index 2a53c4b..5889adc 100644 --- a/tests/Unit/Theme/Controller/ThemeListControllerTest.php +++ b/tests/Unit/Theme/Controller/ThemeListControllerTest.php @@ -54,7 +54,7 @@ public function testThemesListWithoutFilter(): void ->willReturn([$theme]); $themeListController = new ThemeListController($themeListServiceMock); - $resultedThemeList = $themeListController->themesList($themeFilters); + $resultedThemeList = $themeListController->themesList(null); $this->assertSame($resultedThemeList, [$theme]); } diff --git a/tests/Unit/Theme/DataType/ThemeFiltersTest.php b/tests/Unit/Theme/DataType/ThemeFiltersTest.php index 5db0c48..9b972bd 100644 --- a/tests/Unit/Theme/DataType/ThemeFiltersTest.php +++ b/tests/Unit/Theme/DataType/ThemeFiltersTest.php @@ -93,7 +93,13 @@ public function testCreateThemeFilterList(): void $stringFilter = $this->createMock(StringFilter::class); $boolFilter = $this->createMock(BoolFilter::class); - $themeFilterListSpy = ThemeFilters::createThemeFilters($stringFilter, $boolFilter); - $this->assertInstanceOf(ThemeFilters::class, $themeFilterListSpy); + $themeFilterList = ThemeFilters::createThemeFilters($stringFilter, $boolFilter); + $this->assertInstanceOf(ThemeFilters::class, $themeFilterList); + } + + public function testCreateThemeFilterListWithNull(): void + { + $themeFilterList = ThemeFilters::createThemeFilters(null, null); + $this->assertInstanceOf(ThemeFilters::class, $themeFilterList); } }