Skip to content

Instantly share code, notes, and snippets.

@DavertMik
Created March 12, 2020 14:46
Show Gist options
  • Save DavertMik/32afc5bebaea753d54369543dbfda655 to your computer and use it in GitHub Desktop.
Save DavertMik/32afc5bebaea753d54369543dbfda655 to your computer and use it in GitHub Desktop.
Swagger Assertions for Codeception
<?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