The console under console/ has its own session cookie and console guard (UseConsoleSession), so signing out or changing user there leaves the normal interface alone. Links open it in a new window through a one-time handoff key; a signed-out console asks for a PIN code or password on its own login page. Users set their 4-6 digit PIN on the profile's PIN page, and the console's change user dialog takes it on a keypad; five wrong PINs lock PIN sign-in for 15 minutes. Machine counters are cumulative: users record how much a job used and it is added to the latest reading. A maintenance record restarts the whole counter interval from the reading at the record. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Fakes;
|
|
|
|
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
|
use App\Modules\Users\Application\DTOs\UserOption;
|
|
use App\Modules\Users\Application\DTOs\UserSummary;
|
|
use App\Modules\Users\Domain\Enums\Role;
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
use LogicException;
|
|
|
|
/**
|
|
* Users for unit tests of other modules.
|
|
*/
|
|
class FakeUserAccountQueries implements UserAccountQueries
|
|
{
|
|
/** @var array<int, array{string, Role, bool}> name, role, active */
|
|
public array $users = [];
|
|
|
|
public function addUser(int $id, string $name, Role $role = Role::Employee, bool $active = true): void
|
|
{
|
|
$this->users[$id] = [$name, $role, $active];
|
|
}
|
|
|
|
public function findSummary(int $id): ?UserSummary
|
|
{
|
|
throw new LogicException('Not needed in unit tests.');
|
|
}
|
|
|
|
public function paginate(?string $search, int $perPage = 25): LengthAwarePaginator
|
|
{
|
|
throw new LogicException('Not needed in unit tests.');
|
|
}
|
|
|
|
public function pinLoginOptions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function supervisorOptions(?int $exceptUserId = null): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function activeUserOptions(): array
|
|
{
|
|
$options = [];
|
|
|
|
foreach ($this->users as $id => [$name, $role, $active]) {
|
|
if ($active) {
|
|
$options[] = new UserOption($id, $name, $role);
|
|
}
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
|
|
public function namesByIds(array $ids): array
|
|
{
|
|
return array_map(fn (array $user): string => $user[0], array_intersect_key($this->users, array_flip($ids)));
|
|
}
|
|
}
|