fix: called-off dispositions no longer block teamers
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Application;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Teamer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* A called-off teamer is free again: the teamer views ask the assignment for the teamer's
|
||||
* disposition to decide between "eingeteilt" and the application button, so a called-off
|
||||
* disposition must not be handed out there.
|
||||
*/
|
||||
class AssignmentTest extends TestCase
|
||||
{
|
||||
public function testTheActiveDispositionOfATeamerIsReturned(): void
|
||||
{
|
||||
$assignment = new Assignment();
|
||||
$teamer = new Teamer();
|
||||
$disposition = $this->createDisposition($assignment, $teamer);
|
||||
|
||||
$this->assertSame($disposition, $assignment->getActiveDispositionByTeamer($teamer));
|
||||
}
|
||||
|
||||
public function testACalledOffDispositionIsNotReturned(): void
|
||||
{
|
||||
$assignment = new Assignment();
|
||||
$teamer = new Teamer();
|
||||
|
||||
$this
|
||||
->createDisposition($assignment, $teamer)
|
||||
->setStatus(Disposition::STATUS_CALLED_OFF)
|
||||
;
|
||||
|
||||
$this->assertNull($assignment->getActiveDispositionByTeamer($teamer));
|
||||
}
|
||||
|
||||
public function testTheDispositionOfAnotherTeamerIsNotReturned(): void
|
||||
{
|
||||
$assignment = new Assignment();
|
||||
$this->createDisposition($assignment, new Teamer());
|
||||
|
||||
$this->assertNull($assignment->getActiveDispositionByTeamer(new Teamer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A teamer can be called off and disposed again on the same assignment, so both dispositions
|
||||
* live side by side - the active one has to win.
|
||||
*/
|
||||
public function testTheActiveDispositionWinsOverACalledOffOne(): void
|
||||
{
|
||||
$assignment = new Assignment();
|
||||
$teamer = new Teamer();
|
||||
|
||||
$this
|
||||
->createDisposition($assignment, $teamer)
|
||||
->setStatus(Disposition::STATUS_CALLED_OFF)
|
||||
;
|
||||
$disposition = $this->createDisposition($assignment, $teamer);
|
||||
|
||||
$this->assertSame($disposition, $assignment->getActiveDispositionByTeamer($teamer));
|
||||
}
|
||||
|
||||
private function createDisposition(Assignment $assignment, Teamer $teamer): Disposition
|
||||
{
|
||||
$disposition = new Disposition(new Application($assignment, $teamer));
|
||||
$assignment->addDisposition($disposition);
|
||||
|
||||
return $disposition;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user