Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test-up: ## Start test containers (keep running)
@$(TEST_COMPOSE) up -d
@$(TEST_COMPOSE) exec php bin/console d:d:c -n --if-not-exists
@$(TEST_COMPOSE) exec php bin/console d:m:m -n
@$(TEST_COMPOSE) exec php bin/console app:populate:users -n
@$(TEST_COMPOSE) exec php bin/console app:populate:users -n test_user_1 -f Test -l User
@$(TEST_COMPOSE) exec php bin/console app:populate:capitals --purge -n
@$(TEST_COMPOSE) exec php bin/console app:populate:flags --purge -n

Expand Down
17 changes: 12 additions & 5 deletions app/src/Flags/Controller/FlagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public function getStat(#[CurrentUser] $user, AnswerRepository $repository): Res
$result = $repository->findAllGuesses($user->getId());
// TODO move this logic to service
foreach ($result as $key => $item) {
$result[$key]['flag'] = $this->flagsGenerator->getEmojiFlag($item['flagCode']);
$result[$key]['country'] = Countries::getName(strtoupper($item['flagCode']));
$result[$key]['flag'] = $this->flagsGenerator->getEmojiFlag($item['flagCode'], CodeSet::EXTENDED);
$result[$key]['country'] = $this->getCountryName(strtoupper($item['flagCode']));
foreach ($correctResults as $value) {
if ($value['flagCode'] === $result[$key]['flagCode']) {
$shown = (int) $result[$key]['times'];
Expand Down Expand Up @@ -180,8 +180,8 @@ public function getRight(#[CurrentUser] $user, AnswerRepository $repository): Re
$result = $repository->findAllGuesses($user->getId());
// TODO move this logic to service
foreach ($result as $key => $item) {
$result[$key]['flag'] = $this->flagsGenerator->getEmojiFlag($item['flagCode']);
$result[$key]['country'] = Countries::getName(strtoupper($item['flagCode']));
$result[$key]['flag'] = $this->flagsGenerator->getEmojiFlag($item['flagCode'], CodeSet::EXTENDED);
$result[$key]['country'] = $this->getCountryName(strtoupper($item['flagCode']));
foreach ($correctResults as $value) {
if ($value['flagCode'] === $result[$key]['flagCode']) {
$shown = (int) $result[$key]['times'];
Expand All @@ -199,7 +199,14 @@ public function getRight(#[CurrentUser] $user, AnswerRepository $repository): Re
}
}

array_multisort($result, SORT_DESC, SORT_NUMERIC, array_column($result, 'rate'), SORT_DESC, SORT_NUMERIC);
array_multisort(
$result,
SORT_DESC,
SORT_NUMERIC,
array_column($result, 'rate'),
SORT_DESC,
SORT_NUMERIC,
);

return $this->json($result);
}
Expand Down
2 changes: 1 addition & 1 deletion app/tests/Support/Factory/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Flags\Entity\User;
use Doctrine\ORM\EntityManagerInterface;

final class UserFactory
class UserFactory
{
private int $sequence = 0;

Expand Down
17 changes: 17 additions & 0 deletions app/tests/Unit/Service/CountriesGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace App\Tests\Unit\Service;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Countries;

class CountriesGeneratorTest extends TestCase
{
public function testCountryIsFetched(): void
{
// TODO move getCountryName to testable unit and update the test
$this->assertFalse(Countries::exists('AC'));
}
}