From 60713878f0e2f2232aa4e07ed325620b3184bf58 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sat, 19 Mar 2022 22:16:50 +0000 Subject: [PATCH] [TESTS] Load languages prior to remaining fixtures --- components/Language/Entity/Language.php | 6 +++--- docker/tooling/coverage.sh | 1 - tests/fixtures/CoreFixtures.php | 8 ++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/Language/Entity/Language.php b/components/Language/Entity/Language.php index d5e8801151..19a5e69aa9 100644 --- a/components/Language/Entity/Language.php +++ b/components/Language/Entity/Language.php @@ -116,7 +116,7 @@ class Language extends Entity return Cache::getHashMapKey( map_key: 'languages-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( 'languages', $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( '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())); diff --git a/docker/tooling/coverage.sh b/docker/tooling/coverage.sh index 9c046498e7..ec200ee62c 100755 --- a/docker/tooling/coverage.sh +++ b/docker/tooling/coverage.sh @@ -7,7 +7,6 @@ bin/console doctrine:database:drop --force || exit 1 bin/console doctrine:database:create || exit 1 bin/console doctrine:schema:update --force || exit 1 yes yes | bin/console doctrine:fixtures:load || exit 1 -bin/console app:populate_initial_values || exit 1 if [ "$#" -eq 0 ] || [ -z "$*" ]; then vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report diff --git a/tests/fixtures/CoreFixtures.php b/tests/fixtures/CoreFixtures.php index 06c803be44..3534c07c71 100644 --- a/tests/fixtures/CoreFixtures.php +++ b/tests/fixtures/CoreFixtures.php @@ -13,16 +13,24 @@ use App\Entity\Note; use Component\Conversation\Conversation; use Component\Group\Entity\GroupMember; use Component\Group\Entity\LocalGroup; +use Component\Language\Entity\Language; use Component\Notification\Entity\Attention; use Component\Notification\Entity\Notification; use Component\Subscription\Entity\ActorSubscription; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; +use Symfony\Component\Intl\Locales; class CoreFixtures extends Fixture { 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 = []; $local_entities = []; foreach ([