-
-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
tests/Fixtures/TestBundle/ApiResource/Issue6718/Organization.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6718; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\Operation; | ||
|
||
#[ApiResource( | ||
shortName: 'OrganisationIssue6718', | ||
extraProperties: ['rfc_7807_compliant_errors' => true], | ||
operations: [ | ||
new Get( | ||
uriTemplate: '/6718_organisations/{id}', | ||
provider: [self::class, 'itemProvider'], | ||
), | ||
new Get( | ||
uriTemplate: '/6718_users/{userId}/organisation', | ||
uriVariables: [ | ||
'userId', | ||
], | ||
normalizationContext: [ | ||
'item_uri_template' => '/6718_organisations/{id}', | ||
'hydra_prefix' => false, | ||
], | ||
provider: [self::class, 'userOrganizationItemProvider'] | ||
), | ||
], | ||
)] | ||
class Organization | ||
{ | ||
public function __construct(public readonly string $id) | ||
{ | ||
} | ||
|
||
public static function itemProvider(Operation $operation, array $uriVariables = []): ?self | ||
{ | ||
return new self($uriVariables['id']); | ||
} | ||
|
||
public static function userOrganizationItemProvider(): ?self | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Functional; | ||
|
||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; | ||
|
||
class ItemUriTemplateTest extends ApiTestCase | ||
{ | ||
public function testIssue6718(): void | ||
{ | ||
self::createClient()->request('GET', '/6718_users/1/organisation', [ | ||
'headers' => ['accept' => 'application/ld+json'], | ||
]); | ||
$this->assertResponseStatusCodeSame(404); | ||
$this->assertJsonContains(['description' => 'Not Found']); | ||
} | ||
} |