feat: all-season assignments
This commit is contained in:
1 parent
675cec1b69
commit
cf876ed224
119 files changed
+6194
-294
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Twig;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Entity\User;
|
||||
use App\Twig\AppRuntime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* All-season is a flag on top of the status, not a status of its own: a teamer can be an
|
||||
* all-season and an ordinary Bestandsteamer:in at the same time. The general Teamübersicht is
|
||||
* the only place that overlap would otherwise be invisible, since both teamer lists render the
|
||||
* same table and the status column never mentioned the flag.
|
||||
*/
|
||||
class TeamerStatusLabelTest extends TestCase
|
||||
{
|
||||
public function testAnAllSeasonTeamerKeepsTheirOrdinaryStatus(): void
|
||||
{
|
||||
$teamer = $this->createTeamer(Teamer::STATUS_EXISTING, true);
|
||||
|
||||
$this->assertSame('Bestandsteamer:in · Saison', $this->label($teamer));
|
||||
}
|
||||
|
||||
public function testANewTeamerCanAlsoBeAllSeason(): void
|
||||
{
|
||||
$teamer = $this->createTeamer(Teamer::STATUS_NEW, true);
|
||||
|
||||
$this->assertSame('Neuteamer:in · Saison', $this->label($teamer));
|
||||
}
|
||||
|
||||
public function testAnOrdinaryTeamerIsUnmarked(): void
|
||||
{
|
||||
$this->assertSame('Bestandsteamer:in', $this->label($this->createTeamer(Teamer::STATUS_EXISTING, false)));
|
||||
$this->assertSame('Neuteamer:in', $this->label($this->createTeamer(Teamer::STATUS_NEW, false)));
|
||||
}
|
||||
|
||||
/**
|
||||
* A role replaces the status label entirely, but the flag is orthogonal to both - an admin
|
||||
* who is also an all-season teamer has to stay recognisable as one.
|
||||
*/
|
||||
public function testARoleLabelStillCarriesTheMarker(): void
|
||||
{
|
||||
$teamer = $this->createTeamer(Teamer::STATUS_EXISTING, true);
|
||||
$teamer->getUser()->setRoles(['ROLE_MANAGER']);
|
||||
|
||||
$this->assertSame('Reisemanagement · Saison', $this->label($teamer));
|
||||
}
|
||||
|
||||
/**
|
||||
* The dedicated Saisonteamer list is entirely all-season, so repeating it on every row
|
||||
* would say nothing.
|
||||
*/
|
||||
public function testTheMarkerCanBeSuppressed(): void
|
||||
{
|
||||
$teamer = $this->createTeamer(Teamer::STATUS_EXISTING, true);
|
||||
|
||||
$this->assertSame('Bestandsteamer:in', $this->label($teamer, false));
|
||||
}
|
||||
|
||||
private function label(Teamer $teamer, bool $includeAllSeason = true): string
|
||||
{
|
||||
return $this->createRuntime()->teamerStatusLabel($teamer, $includeAllSeason);
|
||||
}
|
||||
|
||||
private function createTeamer(string $status, bool $allSeason): Teamer
|
||||
{
|
||||
$teamer = (new Teamer())
|
||||
->setStatus($status)
|
||||
->setAllSeason($allSeason)
|
||||
;
|
||||
|
||||
// the label reads roles off the user, so every teamer needs one
|
||||
(new User())->setTeamer($teamer);
|
||||
|
||||
return $teamer;
|
||||
}
|
||||
|
||||
private function createRuntime(): AppRuntime
|
||||
{
|
||||
$reflection = new \ReflectionClass(AppRuntime::class);
|
||||
|
||||
return $reflection->newInstanceWithoutConstructor();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user