Skip to content
2 changes: 1 addition & 1 deletion api/src/Entity/Camp.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
* List of all Checklists of this Camp.
* Each Checklist is a List of ChecklistItems.
*/
#[ApiProperty(writable: false, uriTemplate: Checklist::CAMP_SUBRESOURCE_URI_TEMPLATE)]
#[ApiProperty(writable: false, example: '["/checklists/1a2b3c4d"]')]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Checklist::class, mappedBy: 'camp', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC', 'createTime' => 'ASC'])]
Expand Down
2 changes: 1 addition & 1 deletion api/src/Entity/Checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
denormalizationContext: ['groups' => ['write']],
order: ['camp.id', 'name'],
)]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['camp', 'isPrototype'])]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['isPrototype'])]
#[ORM\Entity(repositoryClass: ChecklistRepository::class)]
class Checklist extends BaseEntity implements BelongsToCampInterface, CopyFromPrototypeInterface {
public const CAMP_SUBRESOURCE_URI_TEMPLATE = '/camps/{campId}/checklists{._format}';
Expand Down
42 changes: 20 additions & 22 deletions api/tests/Api/Checklists/ListChecklistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function testListChecklistsIsAllowedForLoggedInUserButFiltered() {
], $response->toArray()['_links']['items']);
}

public function testListChecklistsFilteredByCampIsAllowedForCollaborator() {
public function testListChecklistsAsCampSubresourceIncludesItemsForCollaborator() {
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials()->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId());
$response = static::createClientWithCredentials()->request('GET', '/camps/'.$camp->getId().'/checklists');
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
'totalItems' => 2,
Expand All @@ -61,33 +61,31 @@ public function testListChecklistsFilteredByCampIsAllowedForCollaborator() {
], $response->toArray()['_links']['items']);
}

public function testListChecklistsFilteredByCampIsDeniedForUnrelatedUser() {
public function testListChecklistsAsCampSubresourceReturnsNotFoundForUnrelatedUser() {
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user4unrelated']->getEmail()])
->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId())
->request('GET', '/camps/'.$camp->getId().'/checklists')
;

$this->assertResponseStatusCodeSame(200);

$this->assertJsonContains(['totalItems' => 0]);
$this->assertArrayNotHasKey('items', $response->toArray()['_links']);
$this->assertResponseStatusCodeSame(404);
$this->assertJsonContains(['status' => 404]);
$this->assertArrayNotHasKey('items', $response->toArray(false));
}

public function testListChecklistsFilteredByCampIsDeniedForInactiveCollaborator() {
public function testListChecklistsAsCampSubresourceReturnsNotFoundForInactiveCollaborator() {
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId())
->request('GET', '/camps/'.$camp->getId().'/checklists')
;

$this->assertResponseStatusCodeSame(200);

$this->assertJsonContains(['totalItems' => 0]);
$this->assertArrayNotHasKey('items', $response->toArray()['_links']);
$this->assertResponseStatusCodeSame(404);
$this->assertJsonContains(['status' => 404]);
$this->assertArrayNotHasKey('items', $response->toArray(false));
}

public function testListChecklistsFilteredByCampPrototypeIsAllowedForUnrelatedUser() {
public function testListChecklistsAsCampPrototypeSubresourceIsAllowedForUnrelatedUser() {
$camp = static::getFixture('campPrototype');
$response = static::createClientWithCredentials()->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId());
$response = static::createClientWithCredentials()->request('GET', '/camps/'.$camp->getId().'/checklists');

$this->assertResponseStatusCodeSame(200);

Expand All @@ -97,9 +95,9 @@ public function testListChecklistsFilteredByCampPrototypeIsAllowedForUnrelatedUs
], $response->toArray()['_links']['items']);
}

public function testListChecklistsFilteredBySharedCampIsAllowedForUnrelatedUser() {
public function testListChecklistsAsSharedCampSubresourceIsAllowedForUnrelatedUser() {
$camp = static::getFixture('campShared');
$response = static::createClientWithCredentials()->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId());
$response = static::createClientWithCredentials()->request('GET', '/camps/'.$camp->getId().'/checklists');

$this->assertResponseStatusCodeSame(200);

Expand All @@ -109,10 +107,10 @@ public function testListChecklistsFilteredBySharedCampIsAllowedForUnrelatedUser(
], $response->toArray()['_links']['items']);
}

public function testListChecklistsFilteredBySharedCampIsAllowedForInactiveUser() {
public function testListChecklistsAsSharedCampSubresourceIsAllowedForInactiveUser() {
$camp = static::getFixture('campShared');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId())
->request('GET', '/camps/'.$camp->getId().'/checklists')
;

$this->assertResponseStatusCodeSame(200);
Expand All @@ -123,10 +121,10 @@ public function testListChecklistsFilteredBySharedCampIsAllowedForInactiveUser()
], $response->toArray()['_links']['items']);
}

public function testListChecklistsFilteredBySharedCampIsAllowedForInvitedUser() {
public function testListChecklistsAsSharedCampSubresourceIsAllowedForInvitedUser() {
$camp = static::getFixture('campShared');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user6invited']->getEmail()])
->request('GET', '/checklists?camp=%2Fcamps%2F'.$camp->getId())
->request('GET', '/camps/'.$camp->getId().'/checklists')
;

$this->assertResponseStatusCodeSame(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -87,9 +92,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -175,9 +185,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -263,9 +278,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -351,9 +371,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -439,9 +464,14 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
},
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -527,9 +557,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -615,9 +647,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -703,9 +737,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -791,9 +827,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -879,9 +917,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -967,9 +1007,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -1055,9 +1097,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -1130,9 +1174,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -1220,9 +1266,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down Expand Up @@ -1310,9 +1358,11 @@
"categories": {
"href": "escaped_value"
},
"checklists": {
"href": "escaped_value"
},
"checklists": [
{
"href": "escaped_value"
}
],
"creator": {
"href": "escaped_value"
},
Expand Down
Loading
Loading