Created
June 18, 2019 07:11
-
-
Save DavertMik/c6ef55b596cd4462ef22d5d0fca49438 to your computer and use it in GitHub Desktop.
Codeception Raml Helper
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 | |
namespace Helper; | |
// here you can define custom actions | |
// all public methods declared in helper class will be available in $I | |
class Raml extends \Codeception\Module | |
{ | |
public function parseSchemaFor($type) | |
{ | |
$parser = new \Raml\Parser(); // should be started in `_beforeSuite()` | |
$apiDef = $parser->parse(codecept_root_dir('api.raml'), true); // should be moved to config | |
$types = $apiDef->getTypes(); | |
$type = $types->getTypeByName($type); | |
$type->validate(json_decode($this->getModule('REST')->grabResponse())); | |
if (!$type->isValid()) { | |
$this->fail(implode(', ', $type->getErrors())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment