Fixed PHPunit tests

This commit is contained in:
Jan Böhmer 2023-03-12 22:07:48 +01:00
parent 256d628543
commit c7b9f9e50a

View file

@ -53,12 +53,12 @@ class EntityExporterTest extends WebTestCase
$entities = $this->getEntities(); $entities = $this->getEntities();
$json_without_children = $this->service->exportEntities($entities, ['format' => 'json', 'level' => 'simple']); $json_without_children = $this->service->exportEntities($entities, ['format' => 'json', 'level' => 'simple']);
$this->assertSame('[{"comment":"Test","name":"Enitity 1","type":null},{"comment":"","name":"Enitity 1.1","type":null},{"comment":"","name":"Enitity 2","type":null}]', $this->assertJsonStringEqualsJsonString('[{"name":"Enitity 1","type":"category","full_name":"Enitity 1"},{"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"},{"name":"Enitity 2","type":"category","full_name":"Enitity 2"}]',
$json_without_children); $json_without_children);
$json_with_children = $this->service->exportEntities($entities, $json_with_children = $this->service->exportEntities($entities,
['format' => 'json', 'level' => 'simple', 'include_children' => true]); ['format' => 'json', 'level' => 'simple', 'include_children' => true]);
$this->assertSame('[{"children":[{"children":[],"comment":"","name":"Enitity 1.1","type":null}],"comment":"Test","name":"Enitity 1","type":null},{"children":[],"comment":"","name":"Enitity 1.1","type":null},{"children":[],"comment":"","name":"Enitity 2","type":null}]', $this->assertJsonStringEqualsJsonString('[{"children":[{"children":[],"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"}],"name":"Enitity 1","type":"category","full_name":"Enitity 1"},{"children":[],"name":"Enitity 1.1","type":"category","full_name":"Enitity 1->Enitity 1.1"},{"children":[],"name":"Enitity 2","type":"category","full_name":"Enitity 2"}]',
$json_with_children); $json_with_children);
} }
@ -71,8 +71,7 @@ class EntityExporterTest extends WebTestCase
$request->request->set('level', 'simple'); $request->request->set('level', 'simple');
$response = $this->service->exportEntityFromRequest($entities, $request); $response = $this->service->exportEntityFromRequest($entities, $request);
$this->assertSame('[{"comment":"Test","name":"Enitity 1","type":null},{"comment":"","name":"Enitity 1.1","type":null},{"comment":"","name":"Enitity 2","type":null}]', $this->assertJson($response->getContent());
$response->getContent());
$this->assertSame('application/json', $response->headers->get('Content-Type')); $this->assertSame('application/json', $response->headers->get('Content-Type'));
$this->assertNotEmpty($response->headers->get('Content-Disposition')); $this->assertNotEmpty($response->headers->get('Content-Disposition'));