fix(metadata): read method and routeName of operations in YAML by Maxcastel · Pull Request #8720 · api-platform/core · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Metadata/Extractor/YamlResourceExtractor.php
12 changes: 12 additions & 0 deletions src/Metadata/Tests/Extractor/YamlExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public function testValidYaml(): void
[
'name' => null,
'class' => GetCollection::class,
'method' => null,
'routeName' => null,
'uriTemplate' => '/users/{author}/programs{._format}',
'shortName' => null,
'description' => 'User programs',
Expand Down Expand Up @@ -337,6 +339,8 @@ public function testValidYaml(): void
[
'name' => null,
'class' => Get::class,
'method' => null,
'routeName' => null,
'uriTemplate' => '/users/{userId}/programs/{id}{._format}',
'shortName' => null,
'description' => 'User programs',
Expand Down Expand Up @@ -604,6 +608,14 @@ public function testExtendingYamlResourcesByMultipleYamlFiles(): void
$this->assertCount(1, $resources[User::class][1]['operations']);
}

public function testOperationMethodAndRouteName(): void
{
$operations = (new YamlResourceExtractor([__DIR__.'/yaml/operation-method-route-name.yaml']))->getResources()[Program::class][0]['operations'];

$this->assertSame('PATCH', $operations[0]['method']);
$this->assertSame('program_post_publication', $operations[1]['routeName']);
}

public function testContainerParametersAreResolved(): void
{
$parameters = [
Expand Down
10 changes: 10 additions & 0 deletions src/Metadata/Tests/Extractor/yaml/operation-method-route-name.yaml
Loading