refactor: use english naming for the n8n assignments api

This commit is contained in:
fromme committed 2026-11-07 09:33:54 +01:00
1 parent 0bc77b7463
commit 9583612fdc
10 files changed
+84 -81

No files matched your search

@@ -18,7 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
/**
* The n8n placements feed against real rows in db_test: which assignments it selects, and what a
* The n8n assignments feed against real rows in db_test: which assignments it selects, and what a
* place row says. How places are numbered is pinned in AssignmentTest.
*
* Every test runs inside a transaction that is rolled back, so db_test - shared between branches -
@@ -65,24 +65,24 @@ class ListControllerTest extends WebTestCase
public function testAKeylessRequestIsRejected(): void
{
$this->client->request('GET', '/api/einsaetze?von=2026-12-01&bis=2026-12-31');
$this->client->request('GET', '/api/assignments?from=2026-12-01&to=2026-12-31');
$this->assertSame(Response::HTTP_UNAUTHORIZED, $this->client->getResponse()->getStatusCode());
}
public function testAWrongKeyIsRejected(): void
{
$this->get('von=2026-12-01&bis=2026-12-31', 'wrong-key');
$this->get('from=2026-12-01&to=2026-12-31', 'wrong-key');
$this->assertSame(Response::HTTP_UNAUTHORIZED, $this->client->getResponse()->getStatusCode());
}
/**
* The websites' key must not read placements - it names people.
* The websites' key must not read the assignments feed - it names people.
*/
public function testTheApplicationFormKeyIsForbidden(): void
{
$this->get('von=2026-12-01&bis=2026-12-31', self::APPLICATION_FORM_KEY);
$this->get('from=2026-12-01&to=2026-12-31', self::APPLICATION_FORM_KEY);
$this->assertSame(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
}
@@ -92,23 +92,23 @@ class ListControllerTest extends WebTestCase
$this->get('');
$this->assertSame(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
$this->assertEqualsCanonicalizing(['von', 'bis'], array_column($this->decode()['errors'], 'field'));
$this->assertEqualsCanonicalizing(['from', 'to'], array_column($this->decode()['errors'], 'field'));
}
public function testAnUnusableDateIsRejected(): void
{
$this->get('von=01.12.2026&bis=2026-12-31');
$this->get('from=01.12.2026&to=2026-12-31');
$this->assertSame(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
$this->assertContains('von must be a date as YYYY-MM-DD.', array_column($this->decode()['errors'], 'message'));
$this->assertContains('from must be a date as YYYY-MM-DD.', array_column($this->decode()['errors'], 'message'));
}
public function testAnInvertedRangeIsRejected(): void
{
$this->get('von=2026-12-31&bis=2026-12-01');
$this->get('from=2026-12-31&to=2026-12-01');
$this->assertSame(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
$this->assertSame(['bis must not be before von.'], array_column($this->decode()['errors'], 'message'));
$this->assertSame(['to must not be before from.'], array_column($this->decode()['errors'], 'message'));
}
public function testAFilledPlaceNamesThePerson(): void
@@ -119,7 +119,7 @@ class ListControllerTest extends WebTestCase
$this->contract($disposition, Upload::STATUS_CHECKED);
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertSame([[
@@ -151,7 +151,7 @@ class ListControllerTest extends WebTestCase
$calledOff->setStatus(Disposition::STATUS_CALLED_OFF);
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$rows = $this->decode();
$this->assertSame([$assignment->getId().'-1', $assignment->getId().'-2'], array_column($rows, 'platz_id'));
@@ -170,7 +170,7 @@ class ListControllerTest extends WebTestCase
$this->contract($disposition, Upload::STATUS_PENDING);
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertSame('vertrag', $this->decode()[0]['status']);
$this->assertFalse($this->decode()[0]['vertrag_liegt_vor']);
@@ -181,7 +181,7 @@ class ListControllerTest extends WebTestCase
$this->dispose($this->assignment()->setSkipFormalities(true), $this->teamer());
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertNull($this->decode()[0]['vertrag_liegt_vor']);
}
@@ -195,7 +195,7 @@ class ListControllerTest extends WebTestCase
$this->dispose($this->assignment(), $this->teamer(dateOfBirth: '2000-12-06'));
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertSame([false, true], array_column($this->decode(), 'unter_26'));
}
@@ -208,7 +208,7 @@ class ListControllerTest extends WebTestCase
$this->assignment(from: '2027-01-01', to: '2027-01-08');
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertSame([$startsBefore->getId(), $endsAfter->getId()], array_column($this->decode(), 'einsatz_id'));
}
@@ -225,7 +225,7 @@ class ListControllerTest extends WebTestCase
$this->assignment()->setJobProfile($otherProfile);
$this->entityManager->flush();
$this->get('von=2026-12-01&bis=2026-12-31');
$this->get('from=2026-12-01&to=2026-12-31');
$this->assertSame([$included->getId()], array_column($this->decode(), 'einsatz_id'));
}
@@ -299,7 +299,7 @@ class ListControllerTest extends WebTestCase
{
$this->entityManager->clear();
$this->client->request('GET', '/api/einsaetze?'.$query, server: [
$this->client->request('GET', '/api/assignments?'.$query, server: [
'HTTP_'.strtoupper(str_replace('-', '_', ApiKeyExtractor::HEADER)) => $key,
]);
}