API updadte
This commit is contained in:
50
tests/Api/BundeslandApiTest.php
Normal file
50
tests/Api/BundeslandApiTest.php
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user