Skip to content

Commit

Permalink
remove Get operation from generic /content_nodes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Dec 11, 2022
1 parent 850b423 commit e489ad8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 66 deletions.
9 changes: 0 additions & 9 deletions api/src/Entity/ContentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
*/
#[ApiResource(
operations: [
/*
TO DISCUSS: Api-platform 3.0 behaves differently in that the self link returned by this operations looks like
'/content_nodes/123' instead of '/content_node/column_layouts/123'. We could raise this as an upstream issue to
api-platform (breaking-change). On the other hand, I'm not sure we actually need/want this operation at all
*/

// new Get(
// security: 'is_granted("CAMP_COLLABORATOR", object) or is_granted("CAMP_IS_PROTOTYPE", object)'
// ),
new GetCollection(
security: 'is_authenticated()'
),
Expand Down
66 changes: 9 additions & 57 deletions api/tests/Api/ContentNodes/ContentNode/ReadContentNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,20 @@

use App\Entity\ContentNode;
use App\Tests\Api\ECampApiTestCase;
use Doctrine\Common\Collections\ArrayCollection;

/**
* @internal
*/
class ReadContentNodeTest extends ECampApiTestCase {
// TODO security tests when not logged in or not collaborator
public function testGetSingleContentNodeIsNotImplemented() {
// given
/** @var ContentNode $contentNode */
$contentNode = static::$fixtures['columnLayoutChild1'];

// public function testGetSingleContentNodeIsAllowedForCollaborator() {
// /** @var ContentNode $contentNode */
// $contentNode = static::$fixtures['columnLayoutChild1'];
// $children = new ArrayCollection($contentNode->getChildren());
// $childrenIris = $children->map(fn (ContentNode $contentNode) => $this->getIriFor($contentNode))->toArray();
// when (requesting with anonymous user)
static::createClientWithCredentials()->request('GET', '/content_nodes/'.$contentNode->getId());

// static::createClientWithCredentials()->request('GET', '/content_nodes/'.$contentNode->getId());
// $this->assertResponseStatusCodeSame(200);
// $this->assertJsonContains([
// 'id' => $contentNode->getId(),
// 'instanceName' => $contentNode->instanceName,
// 'slot' => $contentNode->slot,
// 'position' => $contentNode->position,
// 'contentTypeName' => $contentNode->getContentTypeName(),
// 'data' => $contentNode->data,
// '_links' => [
// 'parent' => ['href' => $this->getIriFor($contentNode->parent)],
// // For performance reasons, children must be an array of hrefs, not a single href to a collection!
// // If this test breaks here, that means you probably added a "parent" filter on ContentNode.
// // If you really need that filter, see https://github.com/ecamp/ecamp3/pull/2571#discussion_r844089434
// // for more info on why it was previously removed. You will then probably have to adapt
// // RelatedCollectionLinkNormalizer and add a way to explicitly disable related collection links on a
// // specific relation, so that the "parent" filter can co-exist with children being an array.
// 'children' => $childrenIris,
// 'self' => ['href' => $this->getIriFor('columnLayoutChild1')],
// ],
// ]);
// }

// public function testGetSingleContentNodeIsAllowedInCampPrototype() {
// // given
// /** @var ContentNode $contentNode */
// $contentNode = static::$fixtures['columnLayout1campPrototype'];

// // when (requesting with anonymous user)
// static::createBasicClient()->request('GET', '/content_nodes/'.$contentNode->getId());

// // then
// $this->assertResponseStatusCodeSame(200);
// }

// public function testGetSingleContentNodeIncludesProperRelationLinks() {
// /** @var Storyboard $contentNode */
// $contentNode = static::$fixtures['materialNode1'];

// // when content node is loaded via generic /content_nodes endpoint
// static::createClientWithCredentials()->request('GET', '/content_nodes/'.$contentNode->getId());

// // then the response still includes content-node (here:MaterialNode) specific relation links (injected from RelatedCollectionLinkNormalizer)
// $this->assertJsonContains([
// '_links' => [
// 'materialItems' => ['href' => '/material_items?materialNode='.urlencode($this->getIriFor($contentNode))],
// ],
// ]);
// $this->assertResponseStatusCodeSame(200);
// }
// then
$this->assertResponseStatusCodeSame(404);
}
}

0 comments on commit e489ad8

Please sign in to comment.