Skip to content

Commit

Permalink
Add UnitTests fot checklistNode
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattmann committed Jun 19, 2024
1 parent 655ab78 commit f431137
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 103 deletions.
7 changes: 7 additions & 0 deletions api/fixtures/checklistNodes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
App\Entity\ContentNode\ChecklistNode:
checklistNode1:
root: '@columnLayout1'
parent: '@columnLayout1'
slot: '1'
position: 1
instanceName: <word()>
contentType: '@contentTypeChecklist'
checklistNode3:
root: '@columnLayout3'
parent: '@columnLayout3'
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Api/Activities/ReadActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testGetSingleActivityIsAllowedForMember() {
$this->assertEquals($this->getIriFor($activity->getRootContentNode()), $data['_embedded']['rootContentNode']['_links']['self']['href']);
$this->assertEquals($this->getIriFor($activity->getRootContentNode()), $data['_embedded']['rootContentNode']['_links']['root']['href']);
$this->assertContains(['href' => $this->getIriFor('responsiveLayout1')], $data['_embedded']['rootContentNode']['_links']['children']);
$this->assertEquals(11, count($data['_embedded']['contentNodes']));
$this->assertEquals(12, count($data['_embedded']['contentNodes']));
}

public function testGetSingleActivityIsAllowedForManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Tests\Api\ContentNodes\ChecklistNode;

use App\Entity\ContentNode\ChecklistNode;
use App\Tests\Api\ContentNodes\CreateContentNodeTestCase;

/**
* @internal
*/
class CreateChecklistNodeTest extends CreateContentNodeTestCase {
public function setUp(): void {
parent::setUp();

$this->endpoint = '/content_node/checklist_nodes';
$this->entityClass = ChecklistNode::class;
$this->defaultContentType = static::getFixture('contentTypeChecklist');
}

/**
* payload set up.
*/
public function getExampleWritePayload($attributes = [], $except = []) {
return parent::getExampleWritePayload(
array_merge(
[
'addChecklistItemIds' => null,
'removeChecklistItemIds' => null,
],
$attributes
),
$except
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Tests\Api\ContentNodes\ChecklistNode;

use App\Tests\Api\ContentNodes\DeleteContentNodeTestCase;

/**
* @internal
*/
class DeleteChecklistNodeTest extends DeleteContentNodeTestCase {
public function setUp(): void {
parent::setUp();

$this->endpoint = '/content_node/checklist_nodes';
$this->defaultEntity = static::getFixture('checklistNode3');
}
}
25 changes: 25 additions & 0 deletions api/tests/Api/ContentNodes/ChecklistNode/ListChecklistNodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Tests\Api\ContentNodes\ChecklistNode;

use App\Tests\Api\ContentNodes\ListContentNodeTestCase;

/**
* @internal
*/
class ListChecklistNodeTest extends ListContentNodeTestCase {
public function setUp(): void {
parent::setUp();

$this->endpoint = '/content_node/checklist_nodes';

$this->contentNodesCamp1and2 = [
$this->getIriFor('checklistNode1'),
$this->getIriFor('checklistNode3'),
];

$this->contentNodesCampUnrelated = [
$this->getIriFor('checklistNodeCampUnrelated'),
];
}
}
17 changes: 17 additions & 0 deletions api/tests/Api/ContentNodes/ChecklistNode/ReadChecklistNodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Tests\Api\ContentNodes\ChecklistNode;

use App\Tests\Api\ContentNodes\ReadContentNodeTestCase;

/**
* @internal
*/
class ReadChecklistNodeTest extends ReadContentNodeTestCase {
public function setUp(): void {
parent::setUp();

$this->endpoint = '/content_node/checklist_nodes';
$this->defaultEntity = static::getFixture('checklistNode3');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Tests\Api\ContentNodes\ChecklistNode;

use App\Tests\Api\ContentNodes\UpdateContentNodeTestCase;

/**
* @internal
*/
class UpdateChecklistNodeTest extends UpdateContentNodeTestCase {
public function setUp(): void {
parent::setUp();

$this->endpoint = '/content_node/checklist_nodes';
$this->defaultEntity = static::getFixture('checklistNode1');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testListContentNodesIsAllowedForLoggedInUserButFiltered() {
$response = static::createClientWithCredentials()->request('GET', '/content_nodes');
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
'totalItems' => 22,
'totalItems' => 23,
'_links' => [
'items' => [],
],
Expand All @@ -33,6 +33,7 @@ public function testListContentNodesIsAllowedForLoggedInUserButFiltered() {
]);
$this->assertEqualsCanonicalizing([
['href' => $this->getIriFor('columnLayout1')],
['href' => $this->getIriFor('checklistNode1')],
['href' => $this->getIriFor('columnLayout2')],
['href' => $this->getIriFor('columnLayoutChild1')],
['href' => $this->getIriFor('columnLayout2Child1')],
Expand Down Expand Up @@ -62,7 +63,7 @@ public function testListContentNodesFilteredByPeriodIsAllowedForCollaborator() {
$response = static::createClientWithCredentials()->request('GET', '/content_nodes?period=%2Fperiods%2F'.$period->getId());
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
'totalItems' => 13,
'totalItems' => 14,
'_links' => [
'items' => [],
],
Expand All @@ -72,6 +73,7 @@ public function testListContentNodesFilteredByPeriodIsAllowedForCollaborator() {
]);
$this->assertEqualsCanonicalizing([
['href' => $this->getIriFor('columnLayout1')],
['href' => $this->getIriFor('checklistNode1')],
['href' => $this->getIriFor('columnLayoutChild1')],
['href' => $this->getIriFor('columnLayout3')],
['href' => $this->getIriFor('checklistNode3')],
Expand Down
3 changes: 1 addition & 2 deletions api/tests/Api/ContentNodes/CreateContentNodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ public function testCreatePutsContentNodeAtEndOfSlot() {
],
['position']
));

$this->assertResponseStatusCodeSame(201);
$this->assertJsonContains([
'slot' => '1',
'position' => 1,
'position' => 2,
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testCreateColumnLayoutAllowsMissingPosition() {
static::createClientWithCredentials()->request('POST', $this->endpoint, ['json' => $this->getExampleWritePayload([], ['position'])]);

$this->assertResponseStatusCodeSame(201);
$this->assertJsonContains(['position' => 1]);
$this->assertJsonContains(['position' => 2]);
}

public function testCreateColumnLayoutAllowsMissingInstanceName() {
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Api/SnapshotTests/EndpointPerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function getSnapshotId(): string {

private static function getContentNodeEndpointQueryCountRanges(): array {
return [
'/content_nodes' => [8, 10],
'/content_nodes' => [8, 11],
'/content_node/column_layouts' => [6, 6],
'/content_node/column_layouts/item' => [10, 10],
'/content_node/checklist_nodes' => [6, 7],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@
"rootContentNode": {
"_links": {
"children": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@
"items": [
{
"_links": {
"checklist": "escaped_value",
"checklistItems": [],
"children": [],
"contentType": {
"href": "escaped_value"
},
"parent": {
"href": "escaped_value"
},
"root": {
"href": "escaped_value"
},
"self": {
"href": "escaped_value"
}
},
"contentTypeName": "escaped_value",
"data": "escaped_value",
"id": "escaped_value",
"instanceName": "escaped_value",
"position": "escaped_value",
"slot": "escaped_value"
},
{
"_links": {
"checklistItems": [],
"children": [],
"contentType": {
Expand All @@ -30,6 +53,9 @@
},
"_links": {
"items": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@
{
"_links": {
"children": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,30 @@
},
{
"_links": {
"checklist": "escaped_value",
"checklistItems": [],
"children": [],
"contentType": {
"href": "escaped_value"
},
"parent": {
"href": "escaped_value"
},
"root": {
"href": "escaped_value"
},
"self": {
"href": "escaped_value"
}
},
"contentTypeName": "escaped_value",
"data": "escaped_value",
"id": "escaped_value",
"instanceName": "escaped_value",
"position": "escaped_value",
"slot": "escaped_value"
},
{
"_links": {
"checklistItems": [],
"children": [],
"contentType": {
Expand Down Expand Up @@ -580,6 +603,9 @@
{
"_links": {
"children": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down Expand Up @@ -772,6 +798,9 @@
{
"href": "escaped_value"
},
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@
"position": "escaped_value",
"slot": "escaped_value"
},
{
"_links": {
"checklistItems": [],
"children": [],
"contentType": {
"href": "escaped_value"
},
"parent": {
"href": "escaped_value"
},
"root": {
"href": "escaped_value"
},
"self": {
"href": "escaped_value"
}
},
"contentTypeName": "escaped_value",
"data": "escaped_value",
"id": "escaped_value",
"instanceName": "escaped_value",
"position": "escaped_value",
"slot": "escaped_value"
},
{
"_links": {
"children": [],
Expand Down Expand Up @@ -430,6 +454,9 @@
{
"_links": {
"children": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down Expand Up @@ -464,6 +491,9 @@
"rootContentNode": {
"_links": {
"children": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"_links": {
"checklist": "escaped_value",
"checklistItems": [],
"children": [],
"contentType": {
Expand Down
Loading

0 comments on commit f431137

Please sign in to comment.