diff --git a/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php b/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php index 684a8b6..0f48982 100644 --- a/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php +++ b/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php @@ -22,16 +22,13 @@ class ModuleDataTypeFactoryTest extends UnitTestCase { public function testCreateFromCoreModule() { - $expectedTitle = 'Title in de language'; - $expectedDescription = 'Description in de language'; - $titlesData = [ - 'de' => 'Title in de language', - 'en' => 'Title in en language', + 'de' => uniqid(), + 'en' => uniqid(), ]; $descriptionData = [ - 'de' => 'Description in de language', - 'en' => 'Description in en language', + 'de' => uniqid(), + 'en' => uniqid(), ]; $expectedId = uniqid(); $expectedVersion = uniqid(); @@ -49,14 +46,14 @@ public function testCreateFromCoreModule() $moduleConfigMock->method('getAuthor')->willReturn($expectedAuthor); $moduleConfigMock->method('getUrl')->willReturn($expectedUrl); $moduleConfigMock->method('getEmail')->willReturn($expectedEmail); - $moduleConfigMock->method('isActivated')->willReturn(true); + $moduleConfigMock->method('isActivated')->willReturn((bool)random_int(0, 1)); $languageServiceMock = $this->createMock(LanguageService::class); $languageServiceMock ->method('filterByLanguageAbbreviation') ->willReturnMap([ - [$titlesData, $expectedTitle], - [$descriptionData, $expectedDescription] + [$titlesData, $titlesData['de']], + [$descriptionData, $descriptionData['de']] ]); $moduleDataTypeFactory = new ModuleDataTypeFactory($languageServiceMock); @@ -64,8 +61,8 @@ public function testCreateFromCoreModule() $this->assertSame($expectedId, $moduleDataType->getId()); $this->assertSame($expectedVersion, $moduleDataType->getVersion()); - $this->assertSame($expectedTitle, $moduleDataType->getTitle()); - $this->assertSame($expectedDescription, $moduleDataType->getDescription()); + $this->assertSame($titlesData['de'], $moduleDataType->getTitle()); + $this->assertSame($descriptionData['de'], $moduleDataType->getDescription()); $this->assertSame($expectedThumbnail, $moduleDataType->getThumbnail()); $this->assertSame($expectedAuthor, $moduleDataType->getAuthor()); $this->assertSame($expectedUrl, $moduleDataType->getUrl()); diff --git a/tests/Unit/Module/DataType/ModuleDataTypeTest.php b/tests/Unit/Module/DataType/ModuleDataTypeTest.php index aef4c5b..c89e5bd 100644 --- a/tests/Unit/Module/DataType/ModuleDataTypeTest.php +++ b/tests/Unit/Module/DataType/ModuleDataTypeTest.php @@ -27,7 +27,7 @@ public function testModuleDataType(): void $author = uniqid(); $url = uniqid(); $email = uniqid(); - $active = true; + $active = (bool)random_int(0, 1); $moduleDataType = new ModuleDataType( id: $id, diff --git a/tests/Unit/Module/DataType/ModuleFiltersTest.php b/tests/Unit/Module/DataType/ModuleFiltersTest.php index d0afa0a..5fcb938 100644 --- a/tests/Unit/Module/DataType/ModuleFiltersTest.php +++ b/tests/Unit/Module/DataType/ModuleFiltersTest.php @@ -22,15 +22,15 @@ class ModuleFiltersTest extends TestCase { /** @dataProvider moduleByTitleDataProvider */ public function testFilterModuleByTitle( - string $expectedTitle, bool $expectedResult, bool $enableFilters, ): void { + $title = uniqid(); $stringFilterMock = $this->createMock(StringFilter::class); - $stringFilterMock->method('matches')->willReturn($expectedResult); + $stringFilterMock->expects($this->once())->method('matches')->with($title)->willReturn($expectedResult); $moduleMock = $this->createMock(ModuleDataType::class); - $moduleMock->method('getTitle')->willReturn($expectedTitle); + $moduleMock->expects($this->once())->method('getTitle')->willReturn($title); $moduleFilters = ($enableFilters) ? new ModuleFilters(titleFilter: $stringFilterMock) : new ModuleFilters(); $this->assertEquals($expectedResult, $moduleFilters->filterModuleByTitle($moduleMock)); @@ -38,14 +38,12 @@ public function testFilterModuleByTitle( public static function moduleByTitleDataProvider(): \Generator { - yield "filter module by titles matches" => [ - 'expectedTitle' => 'test module 1', + yield "filter module by title matches" => [ 'expectedResult' => true, 'enableFilters' => true ]; - yield "filter module by titles do not matches" => [ - 'expectedTitle' => 'random module title', + yield "filter module by title do not matches" => [ 'expectedResult' => false, 'enableFilters' => true ]; diff --git a/tests/Unit/Theme/Service/ThemeFilterServiceTest.php b/tests/Unit/Theme/Service/ThemeFilterServiceTest.php index 446771a..9539920 100644 --- a/tests/Unit/Theme/Service/ThemeFilterServiceTest.php +++ b/tests/Unit/Theme/Service/ThemeFilterServiceTest.php @@ -50,8 +50,8 @@ public function testFilterThemes( */ public static function themeFilterResultProvider(): \Generator { - $theme1 = new ThemeDataType('theme1', uniqid(), uniqid(), uniqid(), true); - $theme2 = new ThemeDataType('theme2', uniqid(), uniqid(), uniqid(), false); + $theme1 = new ThemeDataType(uniqid(), uniqid(), uniqid(), uniqid(), true); + $theme2 = new ThemeDataType(uniqid(), uniqid(), uniqid(), uniqid(), false); yield "filter with only second title check is true but status check is false" => [ 'themeList' => [$theme1, $theme2],