Created
March 12, 2020 14:46
-
-
Save DavertMik/32afc5bebaea753d54369543dbfda655 to your computer and use it in GitHub Desktop.
Swagger Assertions for Codeception
This file contains hidden or 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
<?php | |
use Codeception\TestInterface; | |
use FR3D\SwaggerAssertions\PhpUnit\AssertsTrait; | |
use FR3D\SwaggerAssertions\SchemaManager; | |
class Api extends \Codeception\Module | |
{ | |
use AssertsTrait; | |
public function _before(TestInterface $test) | |
{ | |
$this->schemaManager = SchemaManager::fromUri('http://petstore.swagger.io/v2/swagger.json'); | |
} | |
public function seeResponseMatchesSchema($method, $uri, $code = 200) | |
{ | |
$this->assertResponseBodyMatch( | |
json_decode($this->getModule('REST')->response), | |
$this->schemaManager, | |
$uri, | |
$method, | |
$code); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment