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(); } }