Skip to content

Commit

Permalink
OXDEV-8213: Remove unnecessary default values in ThemeFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Jun 28, 2024
1 parent cd872f3 commit d992d30
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Theme/Controller/ThemeListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Theme/DataType/ThemeFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Theme/DataType/ThemeFiltersInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion tests/Unit/Theme/Controller/ThemeListControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
10 changes: 8 additions & 2 deletions tests/Unit/Theme/DataType/ThemeFiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit d992d30

Please sign in to comment.