All Downloads are FREE. Search and download functionalities are using the official Maven repository.

php-symfony.testing.api_test.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
partial_header}}
/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * 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   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
{{#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}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy