Release 2.13 (#4659)

This commit is contained in:
Kevin Papst
2024-03-10 15:35:59 +01:00
committed by GitHub
parent a78e8ed8c4
commit dee90bb15e
79 changed files with 1019 additions and 932 deletions

View File

@@ -96,7 +96,10 @@ class CustomerControllerTest extends APIControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/customers');
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
$this->assertNotEmpty($result);
@@ -109,7 +112,10 @@ class CustomerControllerTest extends APIControllerBaseTest
$query = ['order' => 'ASC', 'orderBy' => 'name', 'visible' => 3, 'term' => 'test'];
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/customers', 'GET', $query);
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
$this->assertNotEmpty($result);
@@ -117,11 +123,19 @@ class CustomerControllerTest extends APIControllerBaseTest
self::assertApiResponseTypeStructure('CustomerCollection', $result[0]);
}
public function testGetEntityIsSecure(): void
{
$this->assertUrlIsSecuredForRole(User::ROLE_USER, '/api/customers/1');
}
public function testGetEntity(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->assertAccessIsGranted($client, '/api/customers/1');
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
self::assertApiResponseTypeStructure('CustomerEntity', $result);
@@ -129,7 +143,7 @@ class CustomerControllerTest extends APIControllerBaseTest
public function testGetEntityWithFullResponse(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$em = $this->getEntityManager();
@@ -165,7 +179,10 @@ class CustomerControllerTest extends APIControllerBaseTest
$em->flush();
$this->assertAccessIsGranted($client, '/api/customers/1');
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
self::assertApiResponseTypeStructure('CustomerEntity', $result);
@@ -191,7 +208,10 @@ class CustomerControllerTest extends APIControllerBaseTest
$this->request($client, '/api/customers', 'POST', [], json_encode($data));
$this->assertTrue($client->getResponse()->isSuccessful());
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
self::assertApiResponseTypeStructure('CustomerEntity', $result);
$this->assertNotEmpty($result['id']);
@@ -209,7 +229,10 @@ class CustomerControllerTest extends APIControllerBaseTest
$this->request($client, '/api/customers', 'POST', [], json_encode($data));
$this->assertTrue($client->getResponse()->isSuccessful());
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
self::assertApiResponseTypeStructure('CustomerEntity', $result);
$this->assertNotEmpty($result['id']);
@@ -262,7 +285,10 @@ class CustomerControllerTest extends APIControllerBaseTest
$this->request($client, '/api/customers/1', 'PATCH', [], json_encode($data));
$this->assertTrue($client->getResponse()->isSuccessful());
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
self::assertApiResponseTypeStructure('CustomerEntity', $result);
$this->assertNotEmpty($result['id']);