Skip to content

Commit 3206429

Browse files
authored
Test input messenger with MongoDB (#2705)
1 parent 6826437 commit 3206429

File tree

7 files changed

+79
-11
lines changed

7 files changed

+79
-11
lines changed

features/graphql/input_output.feature

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Feature: GraphQL DTO input and output
2-
In order to use a hypermedia API
2+
In order to use the GraphQL API
33
As a client software developer
44
I need to be able to use DTOs on my resources as Input or Output objects.
55

66
@createSchema
7-
Scenario: Retrieve an Output with GraphQl
7+
Scenario: Retrieve an Output with GraphQL
88
When I add "Content-Type" header equal to "application/ld+json"
99
And I send a "POST" request to "/dummy_dto_input_outputs" with body:
1010
"""
@@ -162,8 +162,7 @@ Feature: GraphQL DTO input and output
162162
}
163163
"""
164164

165-
@!mongodb
166-
Scenario: Use messenger with graphql and an input where the handler gives a synchronous result
165+
Scenario: Use messenger with GraphQL and an input where the handler gives a synchronous result
167166
When I send the following GraphQL request:
168167
"""
169168
mutation {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Document;
15+
16+
use ApiPlatform\Core\Annotation\ApiProperty;
17+
use ApiPlatform\Core\Annotation\ApiResource;
18+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Dto\MessengerInput;
19+
20+
/**
21+
* @ApiResource(messenger="input", input=MessengerInput::class, graphql={"create"={"input"=MessengerInput::class, "messenger"="input"}})
22+
*/
23+
class MessengerWithInput
24+
{
25+
/**
26+
* @ApiProperty(identifier=true)
27+
*/
28+
public $id;
29+
/**
30+
* @var string
31+
*/
32+
public $name;
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\Document;
15+
16+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\MessengerWithInput;
17+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Dto\MessengerInput;
18+
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
19+
20+
class MessengerWithInputHandler implements MessageHandlerInterface
21+
{
22+
public function __invoke(MessengerInput $data)
23+
{
24+
$object = new MessengerWithInput();
25+
$object->name = 'test';
26+
$object->id = 1;
27+
28+
return $object;
29+
}
30+
}

tests/Fixtures/TestBundle/MessengerHandler/MessengerWithInputHandler.php renamed to tests/Fixtures/TestBundle/MessengerHandler/Entity/MessengerWithInputHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler;
14+
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\Entity;
1515

1616
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Dto\MessengerInput;
1717
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\MessengerWithInput;

tests/Fixtures/app/config/config_common.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ services:
239239
tags:
240240
- { name: 'api_platform.data_transformer' }
241241

242-
app.messenger_handler.messenger_with_inputs:
243-
class: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\MessengerWithInputHandler'
244-
public: false
245-
tags:
246-
- { name: 'messenger.message_handler' }
247-
248242
app.messenger_handler.messenger_with_response:
249243
class: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\MessengerWithResponseHandler'
250244
public: false

tests/Fixtures/app/config/config_orm.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@ services:
7171
public: false
7272
tags:
7373
- { name: 'api_platform.data_persister' }
74+
75+
app.messenger_handler.messenger_with_inputs:
76+
class: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\Entity\MessengerWithInputHandler'
77+
public: false
78+
tags:
79+
- { name: 'messenger.message_handler' }

tests/Fixtures/app/config/config_services_mongodb.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ services:
5656
public: false
5757
tags:
5858
- { name: 'api_platform.data_persister' }
59+
60+
app.messenger_handler.messenger_with_inputs:
61+
class: 'ApiPlatform\Core\Tests\Fixtures\TestBundle\MessengerHandler\Document\MessengerWithInputHandler'
62+
public: false
63+
tags:
64+
- { name: 'messenger.message_handler' }

0 commit comments

Comments
 (0)