fix tests after ifsg implementation
This commit is contained in:
parent
8dd4af1bb6
commit
4378fa2d7d
|
@ -13,10 +13,14 @@ Please ensure that your pull requests follow the [PSR-12](https://www.php-fig.or
|
||||||
You can check that by running
|
You can check that by running
|
||||||
```bash
|
```bash
|
||||||
composer run phpcs
|
composer run phpcs
|
||||||
|
# with docker
|
||||||
|
docker exec engelsystem_dev-es_workspace-1 composer run phpcs
|
||||||
```
|
```
|
||||||
You may auto fix reported issues by running
|
You may auto fix reported issues by running
|
||||||
```bash
|
```bash
|
||||||
composer run phpcbf
|
composer run phpcbf
|
||||||
|
# with docker
|
||||||
|
docker exec engelsystem_dev-es_workspace-1 composer run phpcbf
|
||||||
```
|
```
|
||||||
|
|
||||||
## Pre-commit hooks
|
## Pre-commit hooks
|
||||||
|
|
|
@ -324,7 +324,7 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
# Instruction in accordance with § 43 Para. 1 of the German Infection Protection Act (IfSG)
|
# Instruction in accordance with § 43 Para. 1 of the German Infection Protection Act (IfSG)
|
||||||
'ifsg_enabled' => (bool) env('IFSG_ENABLED', true),
|
'ifsg_enabled' => (bool) env('IFSG_ENABLED', false),
|
||||||
|
|
||||||
// Available locales in /resources/lang/
|
// Available locales in /resources/lang/
|
||||||
'locales' => [
|
'locales' => [
|
||||||
|
|
|
@ -30,6 +30,28 @@ function user_driver_license_required_hint()
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function user_ifsg_certificate_required_hint()
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
// User has already entered data, no hint needed.
|
||||||
|
if ($user->license->ifsg) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$angeltypes = $user->userAngelTypes;
|
||||||
|
foreach ($angeltypes as $angeltype) {
|
||||||
|
if ($angeltype->requires_ifsg_certificate) {
|
||||||
|
return sprintf(
|
||||||
|
__('angeltype.ifsg.required.info.here'),
|
||||||
|
'<a href="' . url('/settings/certificates') . '" class="text-info">' . __('ifsg.info') . '</a>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route user driver licenses actions.
|
* Route user driver licenses actions.
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,7 @@ function header_render_hints()
|
||||||
$hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
|
$hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
|
||||||
$hints_renderer->addHint(render_user_departure_date_hint());
|
$hints_renderer->addHint(render_user_departure_date_hint());
|
||||||
$hints_renderer->addHint(user_driver_license_required_hint());
|
$hints_renderer->addHint(user_driver_license_required_hint());
|
||||||
|
$hints_renderer->addHint(user_ifsg_certificate_required_hint());
|
||||||
|
|
||||||
// Important hints:
|
// Important hints:
|
||||||
$hints_renderer->addHint(render_user_freeloader_hint(), true);
|
$hints_renderer->addHint(render_user_freeloader_hint(), true);
|
||||||
|
|
|
@ -113,14 +113,14 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
|
||||||
),
|
),
|
||||||
$supporter_mode && config('ifsg_enabled') ?
|
$supporter_mode && config('ifsg_enabled') ?
|
||||||
form_info(
|
form_info(
|
||||||
__('requires IfSG certificate'),
|
__('angeltype.ifsg.required'),
|
||||||
$angeltype->requires_ifsg_certificate
|
$angeltype->requires_ifsg_certificate
|
||||||
? __('Yes')
|
? __('Yes')
|
||||||
: __('No')
|
: __('No')
|
||||||
) :
|
) :
|
||||||
form_checkbox(
|
form_checkbox(
|
||||||
'requires_ifsg_certificate',
|
'requires_ifsg_certificate',
|
||||||
__('requires IfSG certificate'),
|
__('angeltype.ifsg.required'),
|
||||||
$angeltype->requires_ifsg_certificate
|
$angeltype->requires_ifsg_certificate
|
||||||
),
|
),
|
||||||
$supporter_mode
|
$supporter_mode
|
||||||
|
@ -175,8 +175,8 @@ function AngelType_view_buttons(
|
||||||
}
|
}
|
||||||
if ($angeltype->requires_ifsg_certificate) {
|
if ($angeltype->requires_ifsg_certificate) {
|
||||||
$buttons[] = button(
|
$buttons[] = button(
|
||||||
user_driver_license_edit_link($user),
|
url('/settings/certificates'),
|
||||||
icon('card-checklist') . __('my ifsg certificate')
|
icon('card-checklist') . __('angeltype.ifsg.own')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ function AngelType_view_buttons(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype->requires_ifsg_certificate && !$user->license->ifsg_certificate) {
|
if ($angeltype->requires_ifsg_certificate && !$user->license->ifsg_certificate) {
|
||||||
error(__('This angeltype requires an ifsg certificate. Please enter your ifsg certificate information!'));
|
error(__('angeltype.ifsg.required.info'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($angeltype->restricted && !$user_angeltype->confirm_user_id) {
|
if ($angeltype->restricted && !$user_angeltype->confirm_user_id) {
|
||||||
|
|
|
@ -567,7 +567,7 @@ function User_view(
|
||||||
) : '',
|
) : '',
|
||||||
config('ifsg_enabled') && ($admin_user_privilege || ($its_me && $needs_drivers_license)) ? button(
|
config('ifsg_enabled') && ($admin_user_privilege || ($its_me && $needs_drivers_license)) ? button(
|
||||||
page_link_to('settings/certificates'),
|
page_link_to('settings/certificates'),
|
||||||
icon('card-checklist') . __('ifsg certificate')
|
icon('card-checklist') . __('ifsg.certificate')
|
||||||
) : '',
|
) : '',
|
||||||
(($admin_user_privilege || $auth->can('admin_arrive')) && !$user_source->state->arrived) ?
|
(($admin_user_privilege || $auth->can('admin_arrive')) && !$user_source->state->arrived) ?
|
||||||
form([
|
form([
|
||||||
|
|
|
@ -2214,26 +2214,35 @@ msgid "settings.certificates.info"
|
||||||
msgstr "Hier kannst du deine gemachte Gesundheitsbelehrung eintragen"
|
msgstr "Hier kannst du deine gemachte Gesundheitsbelehrung eintragen"
|
||||||
|
|
||||||
msgid "settings.ifsg"
|
msgid "settings.ifsg"
|
||||||
msgstr "Frikadellendiplom light: Du wurdest von c3gelb vor Ort nach ISfG §43 belehrt."
|
msgstr "Ich wurde vor Ort nach IfSG §43 (Frikadellendiplom light) belehrt."
|
||||||
|
|
||||||
msgid "settings.ifsg_full"
|
msgid "settings.ifsg_full"
|
||||||
msgstr "Frikadellendiplom: Du hast eine Belehrung nach §43 ISfG bei deinem Gesundheitsamt erhalten und innerhalb von 3 Monaten die Zweitbelehrung durch uns oder deinen Arbeitgeber/Koch/Verein bekommen. Zusätzlich ist die Zweibelehrung nicht älter als zwei Jahre."
|
msgstr "Ich habe eine Belehrung nach §43 IfSG (Frikadellendiplom) bei meinem Gesundheitsamt "
|
||||||
|
"erhalten und innerhalb von 3 Monaten die Zweitbelehrung durch uns oder meinen Arbeitgeber/Koch/Verein bekommen. "
|
||||||
|
"Zusätzlich ist die Zweitbelehrung nicht älter als zwei Jahre."
|
||||||
|
|
||||||
msgid "settings.certificates.success"
|
msgid "settings.certificates.success"
|
||||||
msgstr "Gesundheitsbelehrung wurde erfolgreich geändert."
|
msgstr "Gesundheitsbelehrung wurde erfolgreich geändert."
|
||||||
|
|
||||||
msgid "requires IfSG certificate"
|
msgid "angeltype.ifsg.required"
|
||||||
msgstr "benötigt eine Gesundheitsbelehrung"
|
msgstr "Benötigt eine Gesundheitsbelehrung"
|
||||||
|
|
||||||
msgid "ifsg certificate"
|
msgid "ifsg.certificate"
|
||||||
msgstr "Gesundheitsbelehrung"
|
msgstr "Gesundheitsbelehrung"
|
||||||
|
|
||||||
msgid "my ifsg certificate"
|
msgid "angeltype.ifsg.own"
|
||||||
msgstr "Meine Gesundheitsbelehrung"
|
msgstr "Meine Gesundheitsbelehrung"
|
||||||
|
|
||||||
msgid "This angeltype requires an ifsg certificate. Please enter your ifsg certificate information!"
|
msgid "angeltype.ifsg.required.info"
|
||||||
msgstr "Dieser Engeltyp benötigt eine Gesundheitsbelehrung. Bitte trage deine Gesundheitsbelehrung ein!"
|
msgstr "Dieser Engeltyp benötigt eine Gesundheitsbelehrung. Bitte trage deine Gesundheitsbelehrung ein!"
|
||||||
|
|
||||||
|
msgid "angeltype.ifsg.required.info.here"
|
||||||
|
msgstr "Dieser Engeltyp benötigt eine Gesundheitsbelehrung. "
|
||||||
|
"Bitte trage deine Gesundheitsbelehrung hier ein: %s"
|
||||||
|
|
||||||
|
msgid "ifsg.info"
|
||||||
|
msgstr "Gesundheitsbelehrungs-Infos"
|
||||||
|
|
||||||
msgid "settings.language"
|
msgid "settings.language"
|
||||||
msgstr "Sprache"
|
msgstr "Sprache"
|
||||||
|
|
||||||
|
|
|
@ -315,25 +315,34 @@ msgid "settings.certificates.info"
|
||||||
msgstr "Here you can enter your health instruction"
|
msgstr "Here you can enter your health instruction"
|
||||||
|
|
||||||
msgid "settings.ifsg"
|
msgid "settings.ifsg"
|
||||||
msgstr "Frikadellendiplom light: You were instructed from c3gelb about ISfG §43 on site."
|
msgstr "I was instructed about IfSG §43 (aka Frikadellendiplom light) on site."
|
||||||
|
|
||||||
msgid "settings.ifsg_full"
|
msgid "settings.ifsg_full"
|
||||||
msgstr "Frikadellendiplom: You have gotten the instruction about §43 ISfG from your Health Department and a second instruction from us or your employer/chef/assosiation within 3 months. Additionally your second instruction is not older than 2 years."
|
msgstr "I have gotten the instruction about §43 IfSG (aka Frikadellendiplom) from my Health Department "
|
||||||
|
"and a second instruction from us or my employer/chef/assosiation within 3 months. "
|
||||||
|
"Additionally my second instruction is not older than 2 years."
|
||||||
|
|
||||||
msgid "settings.certificates.success"
|
msgid "settings.certificates.success"
|
||||||
msgstr "Health instruction was changed successfully."
|
msgstr "Health instruction was changed successfully."
|
||||||
|
|
||||||
msgid "requires IfSG certificate"
|
msgid "angeltype.ifsg.required"
|
||||||
msgstr "requires health instruction"
|
msgstr "Requires health instruction"
|
||||||
|
|
||||||
msgid "ifsg certificate"
|
msgid "ifsg.certificate"
|
||||||
msgstr "health instruction"
|
msgstr "health instruction"
|
||||||
|
|
||||||
msgid "my ifsg certificate"
|
msgid "angeltype.ifsg.own"
|
||||||
msgstr "my health instruction"
|
msgstr "my health instruction"
|
||||||
|
|
||||||
msgid "This angeltype requires an ifsg certificate. Please enter your ifsg certificate information!"
|
msgid "angeltype.ifsg.required.info"
|
||||||
msgstr ""This angeltype requires a health instruction. Please enter your health instruction information!""
|
msgstr "This angeltype requires a health instruction. Please enter your health instruction information!"
|
||||||
|
|
||||||
|
msgid "angeltype.ifsg.required.info.here"
|
||||||
|
msgstr "You joined an angeltype which requires a health instruction. "
|
||||||
|
"Please edit your health instruction information here: %s."
|
||||||
|
|
||||||
|
msgid "ifsg.info"
|
||||||
|
msgstr "Health instruction information"
|
||||||
|
|
||||||
msgid "settings.language"
|
msgid "settings.language"
|
||||||
msgstr "Language"
|
msgstr "Language"
|
||||||
|
|
|
@ -174,7 +174,7 @@ class Stats
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function licenses(string $lisence): int
|
public function licenses(string $license): int
|
||||||
{
|
{
|
||||||
$mapping = [
|
$mapping = [
|
||||||
'has_car' => 'has_car',
|
'has_car' => 'has_car',
|
||||||
|
@ -189,7 +189,7 @@ class Stats
|
||||||
|
|
||||||
$query = (new License())
|
$query = (new License())
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->where($mapping[$lisence], true);
|
->where($mapping[$license], true);
|
||||||
|
|
||||||
return $query->count();
|
return $query->count();
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,9 +225,11 @@ class SettingsController extends BaseController
|
||||||
public function ifsgCertificate(): Response
|
public function ifsgCertificate(): Response
|
||||||
{
|
{
|
||||||
$user = $this->auth->user();
|
$user = $this->auth->user();
|
||||||
|
|
||||||
if (!config('ifsg_enabled')) {
|
if (!config('ifsg_enabled')) {
|
||||||
throw new HttpNotFound('ifsg.disabled');
|
throw new HttpNotFound('ifsg.disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->withView(
|
return $this->response->withView(
|
||||||
'pages/settings/certificates',
|
'pages/settings/certificates',
|
||||||
[
|
[
|
||||||
|
@ -243,7 +245,7 @@ class SettingsController extends BaseController
|
||||||
$user = $this->auth->user();
|
$user = $this->auth->user();
|
||||||
$data = $this->validate($request, [
|
$data = $this->validate($request, [
|
||||||
'ifsg_certificate' => 'optional|checked',
|
'ifsg_certificate' => 'optional|checked',
|
||||||
'ifsg_certificate_full' => 'optional|checked'
|
'ifsg_certificate_full' => 'optional|checked',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!config('ifsg_enabled')) {
|
if (!config('ifsg_enabled')) {
|
||||||
|
@ -290,7 +292,7 @@ class SettingsController extends BaseController
|
||||||
$menu[url('/settings/theme')] = 'settings.theme';
|
$menu[url('/settings/theme')] = 'settings.theme';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config('ifsg_disable')) {
|
if (config('ifsg_enable')) {
|
||||||
$menu[url('/settings/certificates')] = 'settings.certificates';
|
$menu[url('/settings/certificates')] = 'settings.certificates';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,10 +86,10 @@ class ControllerTest extends TestCase
|
||||||
->with('metrics return')
|
->with('metrics return')
|
||||||
->willReturn($response);
|
->willReturn($response);
|
||||||
|
|
||||||
$stats->expects($this->exactly(6))
|
$stats->expects($this->exactly(8))
|
||||||
->method('licenses')
|
->method('licenses')
|
||||||
->withConsecutive(['has_car'], ['forklift'], ['car'], ['3.5t'], ['7.5t'], ['12t'])
|
->withConsecutive(['has_car'], ['forklift'], ['car'], ['3.5t'], ['7.5t'], ['12t'], ['ifsg'], ['ifsg_full'])
|
||||||
->willReturnOnConsecutiveCalls(6, 3, 15, 9, 7, 1);
|
->willReturnOnConsecutiveCalls(6, 3, 15, 9, 7, 1, 5, 4);
|
||||||
$stats->expects($this->exactly(2))
|
$stats->expects($this->exactly(2))
|
||||||
->method('arrivedUsers')
|
->method('arrivedUsers')
|
||||||
->withConsecutive([false], [true])
|
->withConsecutive([false], [true])
|
||||||
|
|
|
@ -142,8 +142,8 @@ class StatsTest extends TestCase
|
||||||
$this->assertEquals(0, $stats->licenses('3.5t'));
|
$this->assertEquals(0, $stats->licenses('3.5t'));
|
||||||
$this->assertEquals(0, $stats->licenses('7.5t'));
|
$this->assertEquals(0, $stats->licenses('7.5t'));
|
||||||
$this->assertEquals(1, $stats->licenses('12t'));
|
$this->assertEquals(1, $stats->licenses('12t'));
|
||||||
$this->assertEquals(1, $stats->licenses('ifsg'));
|
$this->assertEquals(0, $stats->licenses('ifsg'));
|
||||||
$this->assertEquals(2, $stats->licenses('ifsg_full'));
|
$this->assertEquals(0, $stats->licenses('ifsg_full'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue