Skip to content

Commit

Permalink
attempt to test api-platform#6810
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Dec 1, 2024
1 parent 2d59c63 commit f97eaed
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6810;

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Operation;

#[GetCollection('/json_ld_context_output', provider: [self::class, 'getData'], output: Output::class)]
class JsonLdContextOutput
{
public function __construct(public string $id)
{
}

public static function getData(Operation $operation, array $uriVariables = [], array $context = []): Output
{
return new Output();
}
}
8 changes: 8 additions & 0 deletions tests/Fixtures/TestBundle/ApiResource/Issue6810/Output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6810;

class Output
{
public string $foo = 'bar';
}
20 changes: 20 additions & 0 deletions tests/Functional/JsonLd.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@
namespace ApiPlatform\Tests\Functional;

use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6810\JsonLdContextOutput;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue6465\Bar;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue6465\Foo;
use ApiPlatform\Tests\Fixtures\TestBundle\Model\GenId;
use ApiPlatform\Tests\SetupClassResourcesTrait;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;

class JsonLd extends ApiTestCase
{
use SetupClassResourcesTrait;

/**
* @return class-string[]
*/
public static function getResources(): array
{
return [JsonLdContextOutput::class];
}

/**
* The input DTO denormalizes an existing Doctrine entity.
*/
Expand All @@ -39,6 +52,13 @@ public function testIssue6465(): void
$this->assertEquals('Bar two', $res['title']);
}

public function testContextWithOutput(): void
{
$response = self::createClient()->request('GET', '/json_ld_context_output');
$res = $response->toArray();
dd($res);
}

protected function setUp(): void
{
self::bootKernel();
Expand Down

0 comments on commit f97eaed

Please sign in to comment.