Skip to content

Commit

Permalink
OXDEV-8215: Refactor and improve some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Aug 6, 2024
1 parent 0e364cd commit c164a1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function testGetThemesValidData(): void
}
}

public function getSut(): ThemeListInfrastructure {
public function getSut(): ThemeListInfrastructure
{
return new ThemeListInfrastructure(
$this->get(CoreThemeFactoryInterface::class),
$this->get(ThemeDataTypeFactoryInterface::class)
$this->get(CoreThemeFactoryInterface::class),
);
}
}
19 changes: 3 additions & 16 deletions tests/Unit/Theme/Infrastructure/ThemeListInfrastructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,8 @@ class ThemeListInfrastructureTest extends TestCase
{
public function testGetThemes(): void
{
$theme1 = [
'title' => uniqid(),
'id' => uniqid(),
'version' => uniqid(),
'description' => uniqid(),
'active' => true
];

$theme2 = [
'title' => uniqid(),
'id' => uniqid(),
'version' => uniqid(),
'description' => uniqid(),
'active' => false
];
$theme1 = $this->createStub(Theme::class);
$theme2 = $this->createStub(Theme::class);

$coreThemeMock = $this->createMock(Theme::class);
$coreThemeMock->expects($this->once())->method('getList')
Expand All @@ -49,7 +36,7 @@ public function testGetThemes(): void

$sut = $this->getSut(coreThemeFactory: $coreThemeFactoryMock);
$actualThemesArray = $sut->getThemes();
$this->assertEquals([$theme1, $theme2], $actualThemesArray);
$this->assertSame([$theme1, $theme2], $actualThemesArray);
}

public function testGetThemesThrowsException(): void
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Theme/Service/ThemeListServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ public function testGetThemeListWithFilters(): void

$themeDataTypeFactoryMock = $this->createMock(ThemeDataTypeFactoryInterface::class);
$themeDataTypeFactoryMock
->expects($this->exactly(2))
->method('createFromCoreTheme')
->willReturnOnConsecutiveCalls($themeList[0], $themeList[1]);
->willReturnMap([
[$themes[0], $themeList[0]],
[$themes[1], $themeList[1]]
]);

$filtersList = new ThemeFilters(
titleFilter: new StringFilter(contains: uniqid()),
Expand Down

0 comments on commit c164a1a

Please sign in to comment.