API updadte

This commit is contained in:
2025-11-08 23:44:33 +01:00
parent 81374cc659
commit 5835eb15ed
29 changed files with 4066 additions and 54 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Tests\Api;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BundeslandApiTest extends WebTestCase
{
public function testGetBundeslaenderPublicAccess(): void
{
$client = static::createClient();
// Test: Bundesländer können ohne API-Key abgerufen werden
$client->request('GET', '/api/bundeslands');
$this->assertResponseIsSuccessful();
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
}
public function testGetSingleBundeslandPublicAccess(): void
{
$client = static::createClient();
// Test: Einzelnes Bundesland kann ohne API-Key abgerufen werden
$client->request('GET', '/api/bundeslands/1');
// Response kann 200 (OK) oder 404 (Not Found) sein, beides ist akzeptabel
$this->assertResponseStatusCodeSame(200);
}
public function testCreateBundeslandRequiresAuthentication(): void
{
$client = static::createClient();
// Test: Bundesland erstellen ohne API-Key sollte fehlschlagen
$client->request(
'POST',
'/api/bundeslands',
[],
[],
['CONTENT_TYPE' => 'application/json'],
json_encode([
'name' => 'Test Bundesland',
'grunderwerbsteuer' => 5.0,
])
);
$this->assertResponseStatusCodeSame(403); // Access Denied (no authentication on this firewall)
}
}