php-symfony.testing.api_test.mustache Maven / Gradle / Ivy
partial_header}}
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the endpoint.
*/
namespace {{apiTestsPackage}};
use {{invokerPackage}}\Configuration;
use {{invokerPackage}}\ApiClient;
use {{invokerPackage}}\ApiException;
use {{invokerPackage}}\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* {{classname}}Test Class Doc Comment
*
* @category Class
* @package {{apiTestsPackage}}
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
{{#operations}}class {{classname}}Test extends WebTestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
{{#operation}}
/**
* Test case for {{{operationId}}}
*
* {{{summary}}}.
*
*/
public function test{{operationIdCamelCase}}()
{
$client = static::createClient();
$path = '{{path}}';
{{#pathParams}}
{{=<% %>=}}
$pattern = '{<%paramName%>}';
<%={{ }}=%>
{{#pattern}}
$data = $this->genTestData('{{pattern}}');
{{/pattern}}
{{^pattern}}
{{#isLong}}
$data = $this->genTestData('\d+');
{{/isLong}}
{{#isInteger}}
$data = $this->genTestData('\d+');
{{/isInteger}}
{{#isString}}
$data = $this->genTestData('[a-z0-9]+');
{{/isString}}
{{#isBoolean}}
$data = $this->genTestData('true|false');
{{/isBoolean}}
{{/pattern}}
$path = str_replace($pattern, $data, $path);
{{/pathParams}}
$crawler = $client->request('{{httpMethod}}', $path);
}
{{/operation}}
protected function genTestData($regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);
}
}
{{/operations}}