Skip to content

Commit

Permalink
Merge 4f43980 into d5f8692
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain committed Mar 31, 2021
2 parents d5f8692 + 4f43980 commit 318fd12
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -28,7 +28,7 @@ jobs:
php-version: ${{ matrix.php }}
extensions: intl, bcmath, curl, openssl, mbstring
ini-values: memory_limit=-1
tools: pecl, composer, php-cs-fixer:2.18.4
tools: pecl, composer, php-cs-fixer
coverage: none
- name: Run PHP-CS-Fixer fix
run: php-cs-fixer fix --dry-run --diff --ansi
Expand Down
5 changes: 5 additions & 0 deletions behat.yml.dist
Expand Up @@ -11,6 +11,7 @@ default:
- 'ApiPlatform\Core\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Core\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Core\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Core\Tests\Behat\MercureContext'
- 'ApiPlatform\Core\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
Expand Down Expand Up @@ -46,6 +47,7 @@ postgres:
- 'ApiPlatform\Core\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Core\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Core\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Core\Tests\Behat\MercureContext'
- 'ApiPlatform\Core\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
Expand All @@ -66,6 +68,7 @@ mongodb:
- 'ApiPlatform\Core\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Core\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Core\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Core\Tests\Behat\MercureContext'
- 'ApiPlatform\Core\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
Expand Down Expand Up @@ -100,6 +103,7 @@ default-coverage:
- 'ApiPlatform\Core\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Core\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Core\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Core\Tests\Behat\MercureContext'
- 'ApiPlatform\Core\Tests\Behat\CoverageContext'
- 'ApiPlatform\Core\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
Expand All @@ -120,6 +124,7 @@ mongodb-coverage:
- 'ApiPlatform\Core\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Core\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Core\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Core\Tests\Behat\MercureContext'
- 'ApiPlatform\Core\Tests\Behat\CoverageContext'
- 'ApiPlatform\Core\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/OpenApiCommand.php
Expand Up @@ -50,7 +50,7 @@ protected function configure()
->setDescription('Dump the Open API documentation')
->addOption('yaml', 'y', InputOption::VALUE_NONE, 'Dump the documentation in YAML')
->addOption('output', 'o', InputOption::VALUE_OPTIONAL, 'Write output to file')
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'Open API version to use (2 or 3) (2 is deprecated)', 3)
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'Open API version to use (2 or 3) (2 is deprecated)', '3')
->addOption('api-gateway', null, InputOption::VALUE_NONE, 'Enable the Amazon API Gateway compatibility mode');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php
Expand Up @@ -71,7 +71,7 @@ protected function configure()
$this
->setDescription('Dump the Swagger v2 documentation')
->addOption('yaml', 'y', InputOption::VALUE_NONE, 'Dump the documentation in YAML')
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, sprintf('OpenAPI version to use (%s)', implode(' or ', $this->swaggerVersions)), $this->swaggerVersions[0] ?? 2)
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, sprintf('OpenAPI version to use (%s)', implode(' or ', $this->swaggerVersions)), (string) ($this->swaggerVersions[0] ?? 2))
->addOption('output', 'o', InputOption::VALUE_OPTIONAL, 'Write output to file')
->addOption('api-gateway', null, InputOption::VALUE_NONE, 'API Gateway compatibility');
}
Expand Down
18 changes: 10 additions & 8 deletions tests/Behat/MercureContext.php
Expand Up @@ -11,10 +11,11 @@

declare(strict_types=1);

use ApiPlatform\Core\Tests\Fixtures\DummyMercurePublisher;
namespace ApiPlatform\Core\Tests\Behat;

use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Symfony\Component\Mercure\Update;
use Psr\Container\ContainerInterface;

/**
* Context for Mercure.
Expand All @@ -23,11 +24,11 @@
*/
final class MercureContext implements Context
{
private $publisher;
private $driverContainer;

public function __construct(DummyMercurePublisher $publisher)
public function __construct(ContainerInterface $driverContainer)
{
$this->publisher = $publisher;
$this->driverContainer = $driverContainer;
}

/**
Expand All @@ -38,9 +39,10 @@ public function theFollowingMercureUpdateShouldHaveBeenSent(string $topics, PySt
$topics = explode(',', $topics);
$update = json_decode($update->getRaw(), true);

/** @var Update $sentUpdate */
foreach ($this->publisher->getUpdates() as $sentUpdate) {
$toMatchTopics = count($topics);
$updateHandler = $this->driverContainer->get('mercure.hub.default.message_handler');

foreach ($updateHandler->getUpdates() as $sentUpdate) {
$toMatchTopics = \count($topics);
foreach ($sentUpdate->getTopics() as $sentTopic) {
foreach ($topics as $topic) {
if (preg_match("@$topic@", $sentTopic)) {
Expand Down
Expand Up @@ -15,7 +15,7 @@

use Symfony\Component\Mercure\Update;

class DummyMercurePublisher
class DummyMercureUpdateHandler
{
private $updates = [];

Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/TestBundle/Entity/User.php
Expand Up @@ -149,6 +149,11 @@ public function getUsername(): string
return (string) $this->email;
}

public function getUserIdentifier(): string
{
return (string) $this->email;
}

public function getRoles(): array
{
return ['ROLE_USER'];
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/app/config/config_behat_mongodb.yml
Expand Up @@ -13,3 +13,5 @@ services:
$jsonApiSchemaFile: '%kernel.project_dir%/../JsonSchema/jsonapi.json'
ApiPlatform\Core\Tests\Behat\JsonHalContext:
$schemaFile: '%kernel.project_dir%/../JsonHal/jsonhal.json'
ApiPlatform\Core\Tests\Behat\MercureContext:
$driverContainer: '@behat.driver.service_container'
2 changes: 2 additions & 0 deletions tests/Fixtures/app/config/config_behat_orm.yml
Expand Up @@ -13,3 +13,5 @@ services:
$jsonApiSchemaFile: '%kernel.project_dir%/../JsonSchema/jsonapi.json'
ApiPlatform\Core\Tests\Behat\JsonHalContext:
$schemaFile: '%kernel.project_dir%/../JsonHal/jsonhal.json'
ApiPlatform\Core\Tests\Behat\MercureContext:
$driverContainer: '@behat.driver.service_container'
5 changes: 3 additions & 2 deletions tests/Fixtures/app/config/config_common.yml
Expand Up @@ -232,10 +232,11 @@ services:
class: ApiPlatform\Core\Tests\Fixtures\TestBundle\Validator\DummyValidationGroupsGenerator
public: true

mercure.hub.default.publisher:
class: ApiPlatform\Core\Tests\Fixtures\DummyMercurePublisher
mercure.hub.default.message_handler:
class: ApiPlatform\Core\Tests\Fixtures\DummyMercureUpdateHandler
public: true
tags: ['messenger.message_handler']
mercure.hub.default.publisher: '@mercure.hub.default.message_handler'

app.serializer.normalizer.override_documentation:
class: ApiPlatform\Core\Tests\Fixtures\TestBundle\Serializer\Normalizer\OverrideDocumentationNormalizer
Expand Down

0 comments on commit 318fd12

Please sign in to comment.