Skip to content

Commit

Permalink
fix tests & remove DB
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Nov 7, 2023
1 parent e3c21c6 commit 5d4615c
Show file tree
Hide file tree
Showing 35 changed files with 63 additions and 101 deletions.
6 changes: 3 additions & 3 deletions app/Components/ApiResults/ApiResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function serialiseResults(): array
}
if (!$data['times']['visible']) {
// results are hidden
$data["submits"] = null;
foreach ($data["teams"] as &$team) {
$team["bonus"] = null;
$data['submits'] = null;
foreach ($data['teams'] as &$team) {
$team['bonus'] = null;
}
}
return $data;
Expand Down
2 changes: 1 addition & 1 deletion app/Components/Map/MapComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function processTeams(): void
$this->teamCountries = [];

foreach ($this->serviceTeam->getTeams($this->forEventId) as $team) {
if (!in_array($team->status, ["participated", "disqualified", "applied", "pending", "approved"])) {
if (!in_array($team->status, ['participated', 'disqualified', 'applied', 'pending', 'approved'])) {
continue;
}
$this->teamCount++;
Expand Down
2 changes: 1 addition & 1 deletion app/Components/PdfGallery/PdfGalleryControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function getPdfs($path, $wwwDir): array
$wwwPath = substr($file->getPathname(), strlen($wwwDir));
$pdfs[] = [
'src' => $wwwPath,
'name' => $file->getBasename(".pdf"),
'name' => $file->getBasename('.pdf'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Components/UpperHomePrague/UpperHomePrague.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function render(): void
{
$this->template->lang = $this->getPresenter()->lang;
$this->template->gamePhaseCalculator = $this->gamePhaseCalculator;
$this->template->render(__DIR__ . DIRECTORY_SEPARATOR . "upperHomePrague.latte");
$this->template->render(__DIR__ . DIRECTORY_SEPARATOR . 'upperHomePrague.latte');
}

protected function createComponentCountdown(): CountdownComponent
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Game/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function getResults(): array
return $this->getCache()->load('results', function (?array &$dependencies): array {
$context = null;
if ($this->httpAuthUser) {
$auth = base64_encode($this->httpAuthUser . ":" . $this->httpAuthPassword);
$auth = base64_encode($this->httpAuthUser . ':' . $this->httpAuthPassword);
$context = stream_context_create([
"http" => [
"header" => "Authorization: Basic $auth"
'http' => [
'header' => "Authorization: Basic $auth"
]
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/GamePhaseCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function isGame(int $period = self::NOW): bool
return $this->checkEvent(
$period,
$this->getGameBegin(),
$this->getGameBegin()->add(new \DateInterval("PT3H")),
$this->getGameBegin()->add(new \DateInterval('PT3H')),
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function localize(): void
{
// Lang is null in error presenter because no rote rule was applied
if (!isset($this->lang) || $this->lang == null) {
$this->lang = "en"; // todo guess language by domain
$this->lang = 'en'; // todo guess language by domain
}

$this->translator->setLang($this->lang);
Expand Down
8 changes: 4 additions & 4 deletions app/Modules/Dsef/ArchiveModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function getEvent(): ModelEvent
$year = $this->eventYear;
$month = $this->eventMonth;
$events = $this->serviceEvent->getEventsByYear(
[$this->context->getParameters()["eventTypeId"]],
[$this->context->getParameters()['eventTypeId']],
intval($year)
);
$events = array_filter($events, function ($event) use ($month) {
Expand Down Expand Up @@ -99,20 +99,20 @@ protected function getNavItems(): array
$items = [];
if (RegistrationPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle(null, "Registrace", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Registration:',
);
}

if (CurrentPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle(null, "Aktuální ročník", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Current:',
);
}

$items[] = new NavItem(
new PageTitle(null, "Archiv", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Archiv', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
':Default:Archive:default',
);
return $items;
Expand Down
8 changes: 4 additions & 4 deletions app/Modules/Dsef/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getEventKey(ModelEvent $event): string

protected function localize(): void
{
$this->lang = "cs";
$this->lang = 'cs';
parent::localize();
}

Expand All @@ -38,15 +38,15 @@ protected function getNavItems(): array
{
$items = [];
$items[] = new NavItem(
new PageTitle(null, "Registrace", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Registration:',
);
$items[] = new NavItem(
new PageTitle(null, "Aktuální ročník", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Current:',
);
$items[] = new NavItem(
new PageTitle(null, "Minulé ročníky", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Archive:',
);

Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Dsef/DefaultModule/ArchivePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function injectServiceEvent(ServiceEventList $serviceEvent): void
*/
public function renderDefault(): void
{
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()["eventTypeId"]]));
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()['eventTypeId']]));
$events = array_filter($events, function ($event) {
//return true;
return $event->end < new \DateTime('now');
Expand Down
6 changes: 3 additions & 3 deletions app/Modules/Dsef/DefaultModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ protected function getNavItems(): array
$items = [];
if (RegistrationPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle(null, "Registrace", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Registrace', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Registration:',
);
}

if (CurrentPresenter::isVisible($this->gamePhaseCalculator)) {
$items[] = new NavItem(
new PageTitle(null, "Aktuální ročník", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Aktuální ročník', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Current:',
);
}

$items[] = new NavItem(
new PageTitle(null, "Minulé ročníky", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Minulé ročníky', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Archive:',
);
return $items;
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/ArchiveModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function getEvent(): ModelEvent
[$year, $month] = explode('-', $this->eventYear);
}
$events = $this->serviceEvent->getEventsByYear(
[$this->context->getParameters()["eventTypeId"]],
[$this->context->getParameters()['eventTypeId']],
intval($year)
);
if (count($events)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fof/DefaultModule/ArchivePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function injectServiceEvent(ServiceEventList $serviceEvent): void
*/
public function renderDefault(): void
{
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()["eventTypeId"]]));
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()['eventTypeId']]));
$events = array_filter($events, function ($event) {
//return true;
return $event->end < new \DateTime('now');
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fol/ArchiveModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function getEvent(): ModelEvent
[$year, $month] = explode('-', $this->eventYear);
}
$events = $this->serviceEvent->getEventsByYear(
[$this->context->getParameters()["eventTypeId"]],
[$this->context->getParameters()['eventTypeId']],
intval($year)
);
if (count($events)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fol/ArchiveModule/ReportsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ReportsPresenter extends BasePresenter
*/
public function renderDefault(): void
{
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . "reports.json");
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'reports.json');
$query = json_decode($data);
$this->template->reports = array_filter($query, function ($item) {
return $item->lang === $this->lang && $item->event_id === $this->getEvent()->eventId;
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fol/DefaultModule/ArchivePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function injectServiceEvent(ServiceEventList $serviceEvent): void
*/
public function renderDefault(): void
{
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()["eventTypeId"]]));
$events = array_reverse($this->serviceEvent->getEvents([$this->context->getParameters()['eventTypeId']]));
$events = array_filter($events, function ($event) {
return $event->end < new \DateTime('now');
});
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Fol/DefaultModule/FaqPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FaqPresenter extends BasePresenter
{
private function loadQuestions(): void
{
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . "faq.json");
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'faq.json');
$query = json_decode($data);
$query = array_filter($query, function ($item) {
return $item->lang === $this->lang;
Expand Down
14 changes: 7 additions & 7 deletions app/Modules/Fykos/DefaultModule/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@ protected function getNavItems(): array
$items = [];

$items[] = new NavItem(
new PageTitle(null, "O nás", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'O nás', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'About:fykosGroup',
);

$items[] = new NavItem(
new PageTitle(null, "Akce", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Akce', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Events:',
);

$items[] = new NavItem(
new PageTitle(null, "Seminář", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Seminář', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'About:fykosCompetition',
);

$items[] = new NavItem(
new PageTitle(null, "Zadání", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Zadání', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Problems:',
);

$items[] = new NavItem(
new PageTitle(null, "Pořadí", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Pořadí', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Results:',
);

$items[] = new NavItem(
new PageTitle(null, "Archiv úloh", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Archiv úloh', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'Default',
);

$items[] = new NavItem(
new PageTitle(null, "Login", 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
new PageTitle(null, 'Login', 'visible-sm-inline glyphicon glyphicon-info-sign'), // TODO
'https://db.fykos.cz',
);
return $items;
Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Vyfuk/Core/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function getNavItems(): array

protected function localize(): void
{
$this->lang = "cs";
$this->lang = 'cs';
parent::localize();
}

Expand Down
7 changes: 0 additions & 7 deletions app/config/config.dsef.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
application:
mapping:
*: App\Modules\Dsef\*Module\*Presenter

database:
default:
dsn: ''
problems:
dsn: ''

services:
- App\RouterFactory::createDsefRouter(%domains%, %router-mapping%)

Expand Down
6 changes: 0 additions & 6 deletions app/config/config.fykos.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ parameters:
router-mapping:
default:
cs:

database:
default:
dsn: ''
problems:
dsn: ''
12 changes: 0 additions & 12 deletions app/config/config.local.neon.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
database:
default:
dsn: 'mysql:host=localhost;dbname=fol-web'
user: %database.user%
password: %database.password%
problems:
dsn: 'mysql:host=localhost;dbname=problems'
user: %database.user%
password: %database.password%
parameters:
fksdbDownloader:
login:
password:
url:
database:
user:
password:
gameApiURL:
5 changes: 1 addition & 4 deletions app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ services:
- App\Models\GamePhaseCalculator(%eventTypeId%)
- App\Models\Game\Connector(%gameApiURL%, %gameApiUser%, %gameApiPass%)

database:
conventions: 'discovered'

extensions:
asset: SixtyEightPublishers\Asset\Bridge\Nette\DI\AssetExtension

parameters:
gameApiURL: "/dev/null"
gameApiURL: /dev/null
i18n:
locales:
cs: cs_CZ.utf-8
Expand Down
14 changes: 1 addition & 13 deletions app/config/config.tester.neon
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
database:
default:
dsn: ''
user: ''
password: ''
problems:
dsn: ''
user: ''
password: ''
parameters:
fksdbDownloader:
login: ''
password: ''
url: "http://127.0.0.1:8082/"
database:
user: ''
password: ''
url: http://127.0.0.1:8082/
gameApiURL: ''
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"scripts": {
"clearTestCache": "rm -rf temp/tester/",
"testPSR": "php -e vendor/squizlabs/php_codesniffer/bin/phpcs --standard=PSR12 app/ tests/",
"testPSR": "php -e vendor/squizlabs/php_codesniffer/bin/phpcs --standard=PSR12 --extensions=php,phpt app/ tests/",
"testPHPStan": "vendor/bin/phpstan analyse --level 5 app tests",
"test": [
"@clearTestCache",
Expand Down
8 changes: 4 additions & 4 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static function boot(string $moduleName): Configurator
->register();

// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . "/../app/config/config." . $moduleName . ".neon");
$configurator->addConfig(__DIR__ . "/../app/config/config.tester.neon");
$configurator->addConfig(__DIR__ . '/../app/config/config.' . $moduleName . '.neon');
$configurator->addConfig(__DIR__ . '/../app/config/config.tester.neon');

return $configurator;
}
Expand All @@ -56,7 +56,7 @@ public static function boot(string $moduleName): Configurator
$container = $configurator->createContainer();

/* Always acquire locks in the order as below! */
define('LOCK_DB', __DIR__ . '/tmp/database.lock');
define('LOCK_UPLOAD', __DIR__ . '/tmp/upload.lock');
const LOCK_DB = __DIR__ . '/tmp/database.lock';
const LOCK_UPLOAD = __DIR__ . '/tmp/upload.lock';
return $container;
// phpcs:enable
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Nette\DI\Container;
use Tester\Assert;
use Tester\TestCase;
use Tracy\Debugger;

abstract class AbstractPageDisplayTestCase extends TestCase
{
Expand All @@ -34,7 +33,7 @@ protected function createPresenter(string $presenterName): Presenter
{
$_COOKIE['_nss'] = '1';
$presenterFactory = $this->container->getByType(IPresenterFactory::class);
/** @var \Nette\Application\UI\Presenter */
/** @var Presenter $presenter */
$presenter = $presenterFactory->createPresenter($presenterName);
$presenter->autoCanonicalize = false;
return $presenter;
Expand Down
Loading

0 comments on commit 5d4615c

Please sign in to comment.