Browse Source

[TESTS] Load languages prior to remaining fixtures

experimental
parent
commit
60713878f0
Signed by: diogo <mail@diogo.site> GPG Key ID: 18D2D35001FBFAB0
3 changed files with 11 additions and 4 deletions
  1. +3
    -3
      components/Language/Entity/Language.php
  2. +0
    -1
      docker/tooling/coverage.sh
  3. +8
    -0
      tests/fixtures/CoreFixtures.php

+ 3
- 3
components/Language/Entity/Language.php View File

@@ -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()));


+ 0
- 1
docker/tooling/coverage.sh View File

@@ -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


+ 8
- 0
tests/fixtures/CoreFixtures.php View File

@@ -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 ([


Loading…
Cancel
Save