feat: expose winter placements to n8n over an api endpoint

This commit is contained in:
fromme committed 2026-11-06 10:09:56 +01:00
1 parent 4ff963d1e2
commit 0bc77b7463
17 files changed
+977 -18

No files matched your search

@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace App\Tests\Security\Voter;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Disposition;
use App\Entity\Teamer;
use App\Security\Voter\ApplicationVoter;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
/**
* A called-off placement frees its place. Counting it would leave the office with raising
* availableDispositions as the only way to re-staff - which adds a place to the n8n feed, where a
* place is a row the Wechselpass hangs off.
*/
class ApplicationVoterTest extends TestCase
{
public function testACalledOffPlaceCanBeStaffedAgain(): void
{
$assignment = (new Assignment())->setAvailableDispositions(2);
$this->dispose($assignment);
$this->dispose($assignment)->setStatus(Disposition::STATUS_CALLED_OFF);
$this->assertSame(VoterInterface::ACCESS_GRANTED, $this->voteDispose($assignment));
}
public function testAFullAssignmentCannotBeStaffed(): void
{
$assignment = (new Assignment())->setAvailableDispositions(2);
$this->dispose($assignment);
$this->dispose($assignment);
$this->assertSame(VoterInterface::ACCESS_DENIED, $this->voteDispose($assignment));
}
private function dispose(Assignment $assignment): Disposition
{
$disposition = new Disposition(new Application($assignment, new Teamer()));
$assignment->addDisposition($disposition);
return $disposition;
}
private function voteDispose(Assignment $assignment): int
{
$security = $this->createStub(Security::class);
$security->method('isGranted')->willReturnCallback(fn (string $role) => 'ROLE_ADMINISTRATIVE' === $role);
return (new ApplicationVoter($security))->vote(
$this->createStub(TokenInterface::class),
new Application($assignment, new Teamer()),
[ApplicationVoter::DISPOSE],
);
}
}