-
Notifications
You must be signed in to change notification settings - Fork 3
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
2 changed files
with
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,8 +62,12 @@ public function testExecuteClass(): void | |
$this->assertEquals($expectedDisplay, $display); | ||
} | ||
|
||
public function testExecuteYaml(): void | ||
public function testExecuteYamlV2(): void | ||
{ | ||
if ($this->isV3()) { | ||
$this->markTestSkipped('Skipping schema V2 test on V3 variable'); | ||
} | ||
|
||
$kernel = self::bootKernel(); | ||
$application = new Application($kernel); | ||
|
||
|
@@ -195,6 +199,141 @@ public function testExecuteYaml(): void | |
} | ||
} | ||
|
||
public function testExecuteYamlV3(): void | ||
{ | ||
if (false === $this->isV3()) { | ||
$this->markTestSkipped('Skipping schema V3 test on V2 variable'); | ||
} | ||
|
||
$kernel = self::bootKernel(); | ||
$application = new Application($kernel); | ||
|
||
$command = $application->find('ferror:asyncapi:dump'); | ||
$commandTester = new CommandTester($command); | ||
$commandTester->execute(['format' => 'yaml']); | ||
|
||
$commandTester->assertCommandIsSuccessful(); | ||
|
||
$display = $commandTester->getDisplay(); | ||
|
||
$expectedDisplay = <<<YAML | ||
asyncapi: 3.0.0 | ||
info: | ||
title: 'Service Example API' | ||
version: 1.2.3 | ||
description: 'This service is in charge of processing user signups' | ||
channels: | ||
user_signed_up: | ||
messages: | ||
UserSignedUp: | ||
\$ref: '#/components/messages/UserSignedUp' | ||
payment_executed: | ||
messages: | ||
PaymentExecuted: | ||
\$ref: '#/components/messages/PaymentExecuted' | ||
product.created: | ||
messages: | ||
ProductCreated: | ||
\$ref: '#/components/messages/ProductCreated' | ||
components: | ||
messages: | ||
UserSignedUp: | ||
payload: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
description: 'Name of the user' | ||
format: string | ||
example: John | ||
email: | ||
type: string | ||
description: 'Email of the user' | ||
format: email | ||
example: [email protected] | ||
age: | ||
type: integer | ||
description: 'Age of the user' | ||
format: int32 | ||
example: '18' | ||
isCitizen: | ||
type: boolean | ||
description: 'Is user a citizen' | ||
format: boolean | ||
example: 'true' | ||
required: | ||
- name | ||
- age | ||
- isCitizen | ||
PaymentExecuted: | ||
payload: | ||
type: object | ||
properties: | ||
amount: | ||
type: number | ||
createdAt: | ||
type: string | ||
required: | ||
- amount | ||
- createdAt | ||
ProductCreated: | ||
payload: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
amount: | ||
type: number | ||
currency: | ||
type: string | ||
isPaid: | ||
type: boolean | ||
createdAt: | ||
type: string | ||
format: date-time | ||
week: | ||
type: integer | ||
payment: | ||
type: string | ||
products: | ||
type: string | ||
tags: | ||
type: string | ||
required: | ||
- id | ||
- amount | ||
- currency | ||
- isPaid | ||
- createdAt | ||
- week | ||
- payment | ||
- products | ||
- tags | ||
servers: | ||
production: | ||
protocol: amqp | ||
description: 'This is production broker.' | ||
host: broker.mycompany.com | ||
staging: | ||
protocol: amqp | ||
description: 'This is staging broker.' | ||
host: broker.mycompany.com | ||
YAML; | ||
|
||
$this->assertEquals($expectedDisplay, $display); | ||
|
||
mkdir(dirname(__DIR__) . '/../var/' . $this->getSchemaVersion()); | ||
|
||
$content = file_put_contents(dirname(__DIR__) . '/../var/' . $this->getSchemaVersion() . '/asyncapi.yaml', $display); | ||
|
||
if (false === $content) { | ||
throw new RuntimeException('Schema file was not save'); | ||
} | ||
} | ||
|
||
public function testExecuteJson(): void | ||
{ | ||
$kernel = self::bootKernel(); | ||
|