refactor: use english for routes, parameters and internal messages
This commit is contained in:
1 parent
bce8f58be3
commit
a88ff7ff24
22 files changed
+106
-135
No files matched your search
@@ -44,11 +44,11 @@ class BookingControllerTest extends WebTestCase
|
||||
{
|
||||
$this->client->loginUser($this->user('[email protected]'));
|
||||
|
||||
$this->client->request('GET', '/buchen/schreibtische/tag/2026-10-01', server: ['HTTP_HX-Request' => 'true']);
|
||||
$this->client->request('GET', '/book/desk/day/2026-10-01', server: ['HTTP_HX-Request' => 'true']);
|
||||
$response = $this->client->getResponse();
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertSame('/buchen/schreibtische?tag=2026-10-01', $response->headers->get('HX-Push-Url'));
|
||||
self::assertSame('/book/desk?date=2026-10-01', $response->headers->get('HX-Push-Url'));
|
||||
self::assertSame(2, substr_count((string) $response->getContent(), 'hx-swap-oob="true"'));
|
||||
self::assertStringContainsString('id="board-calendar"', (string) $response->getContent());
|
||||
self::assertStringContainsString('id="board-floorplan"', (string) $response->getContent());
|
||||
@@ -58,9 +58,9 @@ class BookingControllerTest extends WebTestCase
|
||||
{
|
||||
$this->client->loginUser($this->user('[email protected]'));
|
||||
|
||||
$this->client->request('GET', '/buchen/schreibtische/tag/2026-10-01');
|
||||
$this->client->request('GET', '/book/desk/day/2026-10-01');
|
||||
|
||||
self::assertResponseRedirects('/buchen/schreibtische?tag=2026-10-01');
|
||||
self::assertResponseRedirects('/book/desk?date=2026-10-01');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +146,7 @@ class BookingControllerTest extends WebTestCase
|
||||
$this->client->loginUser($this->user('[email protected]'));
|
||||
$desk = $this->resource('D1');
|
||||
|
||||
$this->client->request('POST', \sprintf('/buchungen/neu/%d/2026-10-01', $desk->getId()), [
|
||||
$this->client->request('POST', \sprintf('/bookings/new/%d/2026-10-01', $desk->getId()), [
|
||||
'booking' => ['date' => '2026-10-01', '_token' => 'nope'],
|
||||
], server: ['HTTP_HX-Request' => 'true']);
|
||||
|
||||
@@ -167,7 +167,7 @@ class BookingControllerTest extends WebTestCase
|
||||
$this->em->flush();
|
||||
|
||||
$this->client->loginUser($this->user('[email protected]'));
|
||||
$this->client->request('POST', \sprintf('/buchungen/%d/freigeben', $booking->getId()), server: ['HTTP_HX-Request' => 'true']);
|
||||
$this->client->request('POST', \sprintf('/bookings/%d/release', $booking->getId()), server: ['HTTP_HX-Request' => 'true']);
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
self::assertSame('body', $response->headers->get('HX-Retarget'));
|
||||
@@ -186,11 +186,11 @@ class BookingControllerTest extends WebTestCase
|
||||
|
||||
// Releasing lives in the edit modal now, not on the floor plan -- clicking your own desk
|
||||
// opens that modal, and the token is rendered there.
|
||||
$crawler = $this->client->request('GET', \sprintf('/buchungen/%d/bearbeiten', $id), server: ['HTTP_HX-Request' => 'true']);
|
||||
$vals = $crawler->filter(\sprintf('[hx-post="/buchungen/%d/freigeben"]', $id))->attr('hx-vals');
|
||||
$crawler = $this->client->request('GET', \sprintf('/bookings/%d/edit', $id), server: ['HTTP_HX-Request' => 'true']);
|
||||
$vals = $crawler->filter(\sprintf('[hx-post="/bookings/%d/release"]', $id))->attr('hx-vals');
|
||||
$token = json_decode((string) $vals, true, flags: \JSON_THROW_ON_ERROR)['_token'];
|
||||
|
||||
$this->client->request('POST', \sprintf('/buchungen/%d/freigeben', $id), ['_token' => $token], server: ['HTTP_HX-Request' => 'true']);
|
||||
$this->client->request('POST', \sprintf('/bookings/%d/release', $id), ['_token' => $token], server: ['HTTP_HX-Request' => 'true']);
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertSame(3, substr_count((string) $this->client->getResponse()->getContent(), 'hx-swap-oob="true"'));
|
||||
@@ -205,9 +205,9 @@ class BookingControllerTest extends WebTestCase
|
||||
$this->em->flush();
|
||||
|
||||
$this->client->loginUser($anna);
|
||||
$crawler = $this->client->request('GET', '/buchen/schreibtische?tag=2026-10-01');
|
||||
$crawler = $this->client->request('GET', '/book/desk?date=2026-10-01');
|
||||
|
||||
self::assertCount(1, $crawler->filter(\sprintf('[hx-get="/buchungen/%d/bearbeiten"]', $booking->getId())));
|
||||
self::assertCount(1, $crawler->filter(\sprintf('[hx-get="/bookings/%d/edit"]', $booking->getId())));
|
||||
}
|
||||
|
||||
public function testBookingPartOfADay(): void
|
||||
@@ -338,7 +338,7 @@ class BookingControllerTest extends WebTestCase
|
||||
|
||||
$crawler = $this->client->request(
|
||||
'GET',
|
||||
\sprintf('/buchungen/neu/%d/2026-10-01?von=09:00&bis=13:00', $desk->getId()),
|
||||
\sprintf('/bookings/new/%d/2026-10-01?from=09:00&to=13:00', $desk->getId()),
|
||||
server: ['HTTP_HX-Request' => 'true'],
|
||||
);
|
||||
|
||||
@@ -351,10 +351,10 @@ class BookingControllerTest extends WebTestCase
|
||||
{
|
||||
$this->client->loginUser($this->user('[email protected]'));
|
||||
|
||||
$this->client->request('GET', '/buchen/schreibtische/tag/2026-10-01?von=09:00&bis=13:00', server: ['HTTP_HX-Request' => 'true']);
|
||||
$this->client->request('GET', '/book/desk/day/2026-10-01?from=09:00&to=13:00', server: ['HTTP_HX-Request' => 'true']);
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertSame('/buchen/schreibtische?tag=2026-10-01&von=09:00&bis=13:00', $this->client->getResponse()->headers->get('HX-Push-Url'));
|
||||
self::assertSame('/book/desk?date=2026-10-01&from=09:00&to=13:00', $this->client->getResponse()->headers->get('HX-Push-Url'));
|
||||
}
|
||||
|
||||
public function testOverridingOneOccurrenceLeavesTheSeriesAlone(): void
|
||||
@@ -375,7 +375,7 @@ class BookingControllerTest extends WebTestCase
|
||||
self::assertCount(4, $occurrences);
|
||||
$first = $occurrences[0];
|
||||
|
||||
$crawler = $this->client->request('GET', \sprintf('/buchungen/%d/bearbeiten', $first->getId()), server: ['HTTP_HX-Request' => 'true']);
|
||||
$crawler = $this->client->request('GET', \sprintf('/bookings/%d/edit', $first->getId()), server: ['HTTP_HX-Request' => 'true']);
|
||||
// Only the span is editable here: the day and the recurrence belong to the series.
|
||||
self::assertCount(0, $crawler->filter('#booking_date'));
|
||||
self::assertCount(0, $crawler->filter('#booking_repeat'));
|
||||
@@ -410,7 +410,7 @@ class BookingControllerTest extends WebTestCase
|
||||
*/
|
||||
private function submitBookingModal(Resource $resource, string $routeDate, array $fields = ['allDay' => '1']): Response
|
||||
{
|
||||
$url = \sprintf('/buchungen/neu/%d/%s', $resource->getId(), $routeDate);
|
||||
$url = \sprintf('/bookings/new/%d/%s', $resource->getId(), $routeDate);
|
||||
$crawler = $this->client->request('GET', $url, server: ['HTTP_HX-Request' => 'true']);
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ class DashboardControllerTest extends WebTestCase
|
||||
foreach (ResourceType::cases() as $type) {
|
||||
self::assertCount(
|
||||
1,
|
||||
$crawler->filter(\sprintf('a[href="/buchen/%s"]', $type->slug())),
|
||||
\sprintf('no dashboard tile links to the %s board', $type->slug()),
|
||||
$crawler->filter(\sprintf('a[href="/book/%s"]', $type->value)),
|
||||
\sprintf('no dashboard tile links to the %s board', $type->value),
|
||||
);
|
||||
self::assertStringContainsString($type->plural(), $crawler->html());
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
$this->client->loginUser($this->user());
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
self::assertCount(1, $crawler->filter('a[href="/buchungen"]'));
|
||||
self::assertCount(1, $crawler->filter('a[href="/bookings"]'));
|
||||
}
|
||||
|
||||
public function testTheNavigationIsGone(): void
|
||||
@@ -86,7 +86,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
$this->client->loginUser($user);
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
$tile = $crawler->filter('a[href="/buchen/schreibtische"]')->text();
|
||||
$tile = $crawler->filter('a[href="/book/desk"]')->text();
|
||||
self::assertStringContainsString('von 2 heute frei', $tile);
|
||||
self::assertStringContainsString('1', $tile);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
$this->client->loginUser($this->user());
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
self::assertStringContainsString('heute alles belegt', $crawler->filter('a[href="/buchen/schreibtische"]')->text());
|
||||
self::assertStringContainsString('heute alles belegt', $crawler->filter('a[href="/book/desk"]')->text());
|
||||
}
|
||||
|
||||
public function testYourOwnBookingIsCalledOutOnTheTile(): void
|
||||
@@ -116,7 +116,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
$this->client->loginUser($user);
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
|
||||
self::assertStringContainsString('D1', $crawler->filter('a[href="/buchen/schreibtische"]')->text());
|
||||
self::assertStringContainsString('D1', $crawler->filter('a[href="/book/desk"]')->text());
|
||||
}
|
||||
|
||||
public function testABoardOnlyShowsItsOwnKindOfResource(): void
|
||||
@@ -126,11 +126,11 @@ class DashboardControllerTest extends WebTestCase
|
||||
|
||||
$this->client->loginUser($this->user());
|
||||
|
||||
$desks = $this->client->request('GET', '/buchen/schreibtische')->html();
|
||||
$desks = $this->client->request('GET', '/book/desk')->html();
|
||||
self::assertStringContainsString('D1', $desks);
|
||||
self::assertStringNotContainsString('P1', $desks);
|
||||
|
||||
$parking = $this->client->request('GET', '/buchen/parkplaetze')->html();
|
||||
$parking = $this->client->request('GET', '/book/parking')->html();
|
||||
self::assertStringContainsString('P1', $parking);
|
||||
self::assertStringNotContainsString('D1', $parking);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
public function testAnUnknownBookingAreaIsNotFound(): void
|
||||
{
|
||||
$this->client->loginUser($this->user());
|
||||
$this->client->request('GET', '/buchen/fahrraeder');
|
||||
$this->client->request('GET', '/book/bikes');
|
||||
|
||||
self::assertResponseStatusCodeSame(404);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class DashboardControllerTest extends WebTestCase
|
||||
|
||||
self::assertStringContainsString(
|
||||
'noch nichts eingerichtet',
|
||||
$this->client->request('GET', '/buchen/parkplaetze')->html(),
|
||||
$this->client->request('GET', '/book/parking')->html(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,35 +9,27 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResourceTypeTest extends TestCase
|
||||
{
|
||||
public function testEverySlugResolvesBackToItsCase(): void
|
||||
/**
|
||||
* The backing value is what appears in a URL, so it has to survive the round trip -- there
|
||||
* is deliberately no separate slug mapping to keep in sync.
|
||||
*/
|
||||
public function testEveryValueResolvesBackToItsCase(): void
|
||||
{
|
||||
foreach (ResourceType::cases() as $type) {
|
||||
self::assertSame($type, ResourceType::fromSlug($type->slug()));
|
||||
self::assertSame($type, ResourceType::tryFrom($type->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testSlugsAreUnique(): void
|
||||
public function testAnUnknownValueResolvesToNothing(): void
|
||||
{
|
||||
$slugs = array_map(static fn (ResourceType $type): string => $type->slug(), ResourceType::cases());
|
||||
|
||||
self::assertSame($slugs, array_unique($slugs));
|
||||
self::assertNull(ResourceType::tryFrom('bikes'));
|
||||
}
|
||||
|
||||
public function testAnUnknownSlugIsRejected(): void
|
||||
public function testValuesAreUrlSafe(): void
|
||||
{
|
||||
$this->expectException(\ValueError::class);
|
||||
|
||||
ResourceType::fromSlug('fahrraeder');
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL slugs are German while the backing values stay English, because the values are
|
||||
* persisted in resource.type and renaming them would need a migration.
|
||||
*/
|
||||
public function testTheSlugIsNotTheStoredValue(): void
|
||||
{
|
||||
self::assertSame('desk', ResourceType::DESK->value);
|
||||
self::assertSame('schreibtische', ResourceType::DESK->slug());
|
||||
foreach (ResourceType::cases() as $type) {
|
||||
self::assertMatchesRegularExpression('/^[a-z]+$/', $type->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class HtmxExceptionListenerFunctionalTest extends WebTestCase
|
||||
{
|
||||
$client = self::createClient();
|
||||
$client->catchExceptions(true);
|
||||
$client->request('GET', '/gibt-es-nicht', server: ['HTTP_HX-Request' => 'true']);
|
||||
$client->request('GET', '/does-not-exist', server: ['HTTP_HX-Request' => 'true']);
|
||||
|
||||
$response = $client->getResponse();
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
@@ -33,7 +33,7 @@ class HtmxExceptionListenerFunctionalTest extends WebTestCase
|
||||
{
|
||||
$client = self::createClient();
|
||||
$client->catchExceptions(true);
|
||||
$client->request('GET', '/gibt-es-nicht');
|
||||
$client->request('GET', '/does-not-exist');
|
||||
|
||||
// Asserting on headers rather than body: in debug mode Symfony's exception page renders
|
||||
// the source of every stack frame, this file included, so any marker string searched for
|
||||
|
||||
@@ -81,7 +81,7 @@ class HtmxExceptionListenerTest extends KernelTestCase
|
||||
{
|
||||
return new ExceptionEvent(
|
||||
self::bootKernel(),
|
||||
Request::create('/buchungen', server: $server),
|
||||
Request::create('/bookings', server: $server),
|
||||
HttpKernelInterface::MAIN_REQUEST,
|
||||
new \RuntimeException('boom'),
|
||||
);
|
||||
|
||||
@@ -16,20 +16,20 @@ class HxTraitTest extends TestCase
|
||||
{
|
||||
public function testHtmxRequestsGetAnHxRedirectInsteadOfA302(): void
|
||||
{
|
||||
$response = $this->controller()->redirectTo($this->request(['HTTP_HX-Request' => 'true']), '/buchungen');
|
||||
$response = $this->controller()->redirectTo($this->request(['HTTP_HX-Request' => 'true']), '/bookings');
|
||||
|
||||
self::assertInstanceOf(HxRedirectResponse::class, $response);
|
||||
self::assertSame('/buchungen', $response->headers->get('HX-Redirect'));
|
||||
self::assertSame('/bookings', $response->headers->get('HX-Redirect'));
|
||||
// A 3xx would be followed by the browser and swapped as a whole page into the fragment.
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function testOrdinaryRequestsGetANormalRedirect(): void
|
||||
{
|
||||
$response = $this->controller()->redirectTo($this->request(), '/buchungen');
|
||||
$response = $this->controller()->redirectTo($this->request(), '/bookings');
|
||||
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
self::assertSame('/buchungen', $response->getTargetUrl());
|
||||
self::assertSame('/bookings', $response->getTargetUrl());
|
||||
}
|
||||
|
||||
public function testOobResponseConcatenatesEveryRequestedBlock(): void
|
||||
@@ -69,8 +69,8 @@ class HxTraitTest extends TestCase
|
||||
|
||||
self::assertFalse($controller->oob('t.html.twig', ['b'])->headers->has('HX-Push-Url'));
|
||||
self::assertSame(
|
||||
'/buchungen?datum=2026-09-13',
|
||||
$controller->oob('t.html.twig', ['b'], [], '/buchungen?datum=2026-09-13')->headers->get('HX-Push-Url'),
|
||||
'/bookings?date=2026-09-13',
|
||||
$controller->oob('t.html.twig', ['b'], [], '/bookings?date=2026-09-13')->headers->get('HX-Push-Url'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class HxTraitTest extends TestCase
|
||||
*/
|
||||
private function request(array $server = []): Request
|
||||
{
|
||||
return Request::create('/buchungen', server: $server);
|
||||
return Request::create('/bookings', server: $server);
|
||||
}
|
||||
|
||||
private function controller(): object
|
||||
|
||||
@@ -56,7 +56,7 @@ class EpClientTest extends KernelTestCase
|
||||
$request->getSession()->set('oauth2state', 'abc');
|
||||
|
||||
$this->expectException(AuthorizationRequestException::class);
|
||||
$this->expectExceptionMessage('keinen Code');
|
||||
$this->expectExceptionMessage('no authorization code');
|
||||
|
||||
$this->client()->fetchAccessToken($request);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class EpClientTest extends KernelTestCase
|
||||
$request->getSession()->set('oauth2state', 'expected');
|
||||
|
||||
$this->expectException(AuthorizationRequestException::class);
|
||||
$this->expectExceptionMessage('state-Parameter');
|
||||
$this->expectExceptionMessage('state parameter does not match');
|
||||
|
||||
$this->client()->fetchAccessToken($request);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user