API updadte
This commit is contained in:
49
tests/Api/HeizungstypApiTest.php
Normal file
49
tests/Api/HeizungstypApiTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Api;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class HeizungstypApiTest extends WebTestCase
|
||||
{
|
||||
public function testGetHeizungstypenPublicAccess(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
// Test: Heizungstypen können ohne API-Key abgerufen werden
|
||||
$client->request('GET', '/api/heizungstyps');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
}
|
||||
|
||||
public function testGetSingleHeizungstypPublicAccess(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
// Test: Einzelner Heizungstyp kann ohne API-Key abgerufen werden
|
||||
$client->request('GET', '/api/heizungstyps/1');
|
||||
|
||||
// Response kann 200 (OK) oder 404 (Not Found) sein
|
||||
$this->assertResponseStatusCodeSame(200);
|
||||
}
|
||||
|
||||
public function testCreateHeizungstypRequiresAuthentication(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
// Test: Heizungstyp erstellen ohne API-Key sollte fehlschlagen
|
||||
$client->request(
|
||||
'POST',
|
||||
'/api/heizungstyps',
|
||||
[],
|
||||
[],
|
||||
['CONTENT_TYPE' => 'application/json'],
|
||||
json_encode([
|
||||
'name' => 'Test Heizung',
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertResponseStatusCodeSame(401); // Unauthorized
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user