[TESTS] Load languages prior to remaining fixtures

This commit is contained in:
Diogo Peralta Cordeiro 2022-03-19 22:16:50 +00:00
parent 06c67b31c2
commit 60713878f0
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 11 additions and 4 deletions

View File

@ -116,7 +116,7 @@ class Language extends Entity
return Cache::getHashMapKey( return Cache::getHashMapKey(
map_key: 'languages-id', map_key: 'languages-id',
key: (string) $id, key: (string) $id,
calculate_map: fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => (string) $l->getId()), calculate_map: fn () => F\reindex(DB::dql('SELECT l FROM \Component\Language\Entity\Language AS l'), fn (self $l) => (string) $l->getId()),
); );
} }
@ -125,7 +125,7 @@ class Language extends Entity
return Cache::getHashMapKey( return Cache::getHashMapKey(
'languages', 'languages',
$locale, $locale,
calculate_map: fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => $l->getLocale()), calculate_map: fn () => F\reindex(DB::dql('SELECT l FROM \Component\Language\Entity\Language AS l'), fn (self $l) => $l->getLocale()),
); );
} }
@ -138,7 +138,7 @@ class Language extends Entity
{ {
$langs = Cache::getHashMap( $langs = Cache::getHashMap(
'languages', 'languages',
fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => $l->getLocale()), fn () => F\reindex(DB::dql('SELECT l FROM \Component\Language\Entity\Language AS l'), fn (self $l) => $l->getLocale()),
); );
return array_merge(...F\map(array_values($langs), fn ($l) => $l->toChoiceFormat())); return array_merge(...F\map(array_values($langs), fn ($l) => $l->toChoiceFormat()));

View File

@ -7,7 +7,6 @@ bin/console doctrine:database:drop --force || exit 1
bin/console doctrine:database:create || exit 1 bin/console doctrine:database:create || exit 1
bin/console doctrine:schema:update --force || exit 1 bin/console doctrine:schema:update --force || exit 1
yes yes | bin/console doctrine:fixtures:load || exit 1 yes yes | bin/console doctrine:fixtures:load || exit 1
bin/console app:populate_initial_values || exit 1
if [ "$#" -eq 0 ] || [ -z "$*" ]; then if [ "$#" -eq 0 ] || [ -z "$*" ]; then
vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report

View File

@ -13,16 +13,24 @@ use App\Entity\Note;
use Component\Conversation\Conversation; use Component\Conversation\Conversation;
use Component\Group\Entity\GroupMember; use Component\Group\Entity\GroupMember;
use Component\Group\Entity\LocalGroup; use Component\Group\Entity\LocalGroup;
use Component\Language\Entity\Language;
use Component\Notification\Entity\Attention; use Component\Notification\Entity\Attention;
use Component\Notification\Entity\Notification; use Component\Notification\Entity\Notification;
use Component\Subscription\Entity\ActorSubscription; use Component\Subscription\Entity\ActorSubscription;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Intl\Locales;
class CoreFixtures extends Fixture class CoreFixtures extends Fixture
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
// Populate Initial Language values
foreach (Locales::getNames() as $key => $name) {
$manager->persist(Language::create(['locale' => $key, 'short_display' => $key, 'long_display' => $name]));
}
$manager->flush();
$actors = []; $actors = [];
$local_entities = []; $local_entities = [];
foreach ([ foreach ([