-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Added integration test coverage for the use case
- Loading branch information
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Core\Repository\ContentService; | ||
|
||
use Ibexa\Tests\Integration\Core\RepositoryTestCase; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
final class MaxLanguagesContentServiceTest extends RepositoryTestCase | ||
{ | ||
/** @var list<array{languageCode: string, name: string }> */ | ||
private static array $languagesRawList = []; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
parent::setUpBeforeClass(); | ||
|
||
self::$languagesRawList = Yaml::parseFile(dirname(__DIR__) . '/_fixtures/max_languages.yaml'); | ||
} | ||
|
||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->prepareMaxLanguages(); | ||
} | ||
|
||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception | ||
*/ | ||
public function testCreateContent(): void | ||
{ | ||
$names = array_merge(...array_map( | ||
static fn (array $languageData): array => [ | ||
$languageData['languageCode'] => $languageData['name'] . ' name', | ||
], | ||
self::$languagesRawList | ||
)); | ||
$this->createFolder($names); | ||
} | ||
|
||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException | ||
*/ | ||
private function prepareMaxLanguages(): void | ||
{ | ||
$languageService = self::getLanguageService(); | ||
|
||
foreach (self::$languagesRawList as $languageData) { | ||
$languageCreateStruct = $languageService->newLanguageCreateStruct(); | ||
$languageCreateStruct->languageCode = $languageData['languageCode']; | ||
$languageCreateStruct->name = $languageData['name']; | ||
$languageService->createLanguage($languageCreateStruct); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
tests/integration/Core/Repository/_fixtures/max_languages.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
- { languageCode: alb-SQ, name: Albanian } | ||
- { languageCode: ara-AR, name: Arabic } | ||
- { languageCode: aze-AZ, name: Azerbaijani } | ||
- { languageCode: bos-BS, name: Bosnian } | ||
- { languageCode: cha-CH, name: Chamorro } | ||
- { languageCode: chi-ZH, name: Chinese } | ||
- { languageCode: cze-CS, name: Czech } | ||
- { languageCode: dan-DA, name: Danish } | ||
- { languageCode: dut-NL, name: Dutch (Flemish) } | ||
#- { languageCode: eng-GB, name: English (United Kingdom) } # Pre-exists in the initial db fixture | ||
#- { languageCode: eng-US, name: English (United States) } # Pre-exists in the initial db fixture | ||
- { languageCode: eng-AU, name: English (Australia) } | ||
- { languageCode: epo-EO, name: Esperanto } | ||
- { languageCode: esp-ES, name: Spanish } | ||
- { languageCode: esp-MX, name: Spanish (Mexico) } | ||
- { languageCode: est-ET, name: Estonian } | ||
- { languageCode: fas-FA, name: Persian (Farsi) } | ||
- { languageCode: fin-FI, name: Finnish } | ||
- { languageCode: fre-FR, name: French (France) } | ||
- { languageCode: fre-BE, name: French (Belgium) } | ||
- { languageCode: fre-CA, name: French (Canada) } | ||
- { languageCode: fre-CH, name: French (Switzerland) } | ||
- { languageCode: fre-LU, name: French (Luxembourg) } | ||
- { languageCode: geo-KA, name: Georgian } | ||
#- { languageCode: ger-DE, name: German (Germany) } # Pre-exists in the initial db fixture | ||
- { languageCode: ger-AT, name: German (Austria) } | ||
- { languageCode: ger-CH, name: German (Switzerland) } | ||
- { languageCode: ger-LI, name: German (Liechtenstein) } | ||
- { languageCode: ger-LU, name: German (Luxembourg) } | ||
- { languageCode: gle-GA, name: Irish } | ||
- { languageCode: gla-GD, name: Scottish (Gaelic) } | ||
- { languageCode: gre-EL, name: Greek } | ||
- { languageCode: hin-HI, name: Hebrew } | ||
- { languageCode: heb-HE, name: Hebrew } | ||
- { languageCode: hrv-HR, name: Croatian } | ||
- { languageCode: hun-HU, name: Hungarian } | ||
- { languageCode: ind-ID, name: Indonesian } | ||
- { languageCode: isl-IS, name: Icelandic } | ||
- { languageCode: ita-IT, name: Italian } | ||
- { languageCode: jpn-JA, name: Japanese } | ||
- { languageCode: kor-KO, name: Korean } | ||
- { languageCode: lat-LA, name: Latin } | ||
- { languageCode: lav-LV, name: Latvian } | ||
- { languageCode: lit-LT, name: Lithuanian } | ||
- { languageCode: mao-MI, name: Maori (New Zealand) } | ||
- { languageCode: may-MS, name: Malay } | ||
- { languageCode: nor-NO, name: Norwegian } | ||
- { languageCode: pol-PL, name: Polish } | ||
- { languageCode: por-PT, name: Portuguese (Portugal) } | ||
- { languageCode: por-BR, name: Portuguese (Brazil) } | ||
- { languageCode: rum-RO, name: Romanian } | ||
- { languageCode: slo-SK, name: Slovak } | ||
- { languageCode: swe-SV, name: Swedish } | ||
- { languageCode: bul-BG, name: Bulgarian } | ||
- { languageCode: swa-SW, name: Swahili (Swahili) } | ||
- { languageCode: tha-TH, name: Thai } | ||
- { languageCode: tib-BO, name: Tibetan } | ||
- { languageCode: tlh-TL, name: Klingon } | ||
- { languageCode: tur-TR, name: Turkish } | ||
- { languageCode: ukr-UK, name: Ukrainian } | ||
- { languageCode: wel-CY, name: Welsh (Swahili) } | ||
- { languageCode: yid-YI, name: Yiddish } |