forked from cebe/php-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallbackTest.php
More file actions
37 lines (32 loc) · 1.09 KB
/
Copy pathCallbackTest.php
File metadata and controls
37 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use cebe\openapi\Reader;
use cebe\openapi\spec\Callback;
/**
* @covers \cebe\openapi\spec\Callback
*/
class CallbackTest extends \PHPUnit\Framework\TestCase
{
public function testRead()
{
/** @var $callback \cebe\openapi\spec\Callback */
$callback = Reader::readFromYaml(<<<'YAML'
'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}':
post:
requestBody:
description: Callback payload
content:
'application/json':
schema:
$ref: '#/components/schemas/SomePayload'
responses:
'200':
description: webhook successfully processed and no retries will be performed
YAML
, Callback::class);
$result = $callback->validate();
$this->assertEquals([], $callback->getErrors());
$this->assertTrue($result);
$this->assertEquals('http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}', $callback->getUrl());
$this->assertInstanceOf(\cebe\openapi\spec\PathItem::class, $callback->getRequest());
}
}