forked from loafle/openapi-generator-original
[PHP] Enhance Symfony generator (#12532)
* Enhance Symfony generator - Add missing typehints - Add missing use statements - Simplify model ctor - Change fallthrough Exception to Throwable - prevent storing result of void methods - fix validate method - add default null values to model properties - simplify API interface return values - fix/rework default value implementation - fix optional params deprecation warnings - .. For more details check out the PR: https://github.com/OpenAPITools/openapi-generator/pull/12532 * Enhance Symfony generator Tests - Skip risky tests - Fix type hint error - Fix class exists tests - Fix broken doc block - Enhance annotations - Update phpunit.xml.dist - Fix test config resource location
This commit is contained in:
@@ -28,10 +28,6 @@
|
||||
|
||||
namespace OpenAPI\Server\Tests\Api;
|
||||
|
||||
use OpenAPI\Server\Configuration;
|
||||
use OpenAPI\Server\ApiClient;
|
||||
use OpenAPI\Server\ApiException;
|
||||
use OpenAPI\Server\ObjectSerializer;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @package OpenAPI\Server\Tests\Api
|
||||
* @author openapi-generator contributors
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPI\Server\Api\PetApiInterface
|
||||
*/
|
||||
class PetApiInterfaceTest extends WebTestCase
|
||||
{
|
||||
@@ -85,13 +82,14 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Add a new pet to the store.
|
||||
*
|
||||
*/
|
||||
public function testAddPet()
|
||||
public function testAddPet(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/pet';
|
||||
|
||||
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for addPet not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +98,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Deletes a pet.
|
||||
*
|
||||
*/
|
||||
public function testDeletePet()
|
||||
public function testDeletePet(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -110,6 +108,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('DELETE', $path);
|
||||
$this->markTestSkipped('Test for deletePet not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,13 +117,14 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Finds Pets by status.
|
||||
*
|
||||
*/
|
||||
public function testFindPetsByStatus()
|
||||
public function testFindPetsByStatus(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/pet/findByStatus';
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for findPetsByStatus not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,13 +133,14 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Finds Pets by tags.
|
||||
*
|
||||
*/
|
||||
public function testFindPetsByTags()
|
||||
public function testFindPetsByTags(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/pet/findByTags';
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for findPetsByTags not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +149,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Find pet by ID.
|
||||
*
|
||||
*/
|
||||
public function testGetPetById()
|
||||
public function testGetPetById(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -158,6 +159,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for getPetById not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,13 +168,14 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Update an existing pet.
|
||||
*
|
||||
*/
|
||||
public function testUpdatePet()
|
||||
public function testUpdatePet(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/pet';
|
||||
|
||||
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for updatePet not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +184,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* Updates a pet in the store with form data.
|
||||
*
|
||||
*/
|
||||
public function testUpdatePetWithForm()
|
||||
public function testUpdatePetWithForm(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -191,6 +194,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('POST', $path);
|
||||
$this->markTestSkipped('Test for updatePetWithForm not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +203,7 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
* uploads an image.
|
||||
*
|
||||
*/
|
||||
public function testUploadFile()
|
||||
public function testUploadFile(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -209,13 +213,18 @@ class PetApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('POST', $path);
|
||||
$this->markTestSkipped('Test for uploadFile not implemented');
|
||||
}
|
||||
|
||||
protected function genTestData($regexp)
|
||||
/**
|
||||
* @param string $regexp
|
||||
* @return mixed
|
||||
*/
|
||||
protected function genTestData(string $regexp)
|
||||
{
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
|
||||
|
||||
return $generator->visit($ast);
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
namespace OpenAPI\Server\Tests\Api;
|
||||
|
||||
use OpenAPI\Server\Configuration;
|
||||
use OpenAPI\Server\ApiClient;
|
||||
use OpenAPI\Server\ApiException;
|
||||
use OpenAPI\Server\ObjectSerializer;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @package OpenAPI\Server\Tests\Api
|
||||
* @author openapi-generator contributors
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPI\Server\Api\StoreApiInterface
|
||||
*/
|
||||
class StoreApiInterfaceTest extends WebTestCase
|
||||
{
|
||||
@@ -85,7 +82,7 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
* Delete purchase order by ID.
|
||||
*
|
||||
*/
|
||||
public function testDeleteOrder()
|
||||
public function testDeleteOrder(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -95,6 +92,7 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('DELETE', $path);
|
||||
$this->markTestSkipped('Test for deleteOrder not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,13 +101,14 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
* Returns pet inventories by status.
|
||||
*
|
||||
*/
|
||||
public function testGetInventory()
|
||||
public function testGetInventory(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/store/inventory';
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for getInventory not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +117,7 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
* Find purchase order by ID.
|
||||
*
|
||||
*/
|
||||
public function testGetOrderById()
|
||||
public function testGetOrderById(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -128,6 +127,7 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for getOrderById not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,20 +136,25 @@ class StoreApiInterfaceTest extends WebTestCase
|
||||
* Place an order for a pet.
|
||||
*
|
||||
*/
|
||||
public function testPlaceOrder()
|
||||
public function testPlaceOrder(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/store/order';
|
||||
|
||||
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for placeOrder not implemented');
|
||||
}
|
||||
|
||||
protected function genTestData($regexp)
|
||||
/**
|
||||
* @param string $regexp
|
||||
* @return mixed
|
||||
*/
|
||||
protected function genTestData(string $regexp)
|
||||
{
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
|
||||
|
||||
return $generator->visit($ast);
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
namespace OpenAPI\Server\Tests\Api;
|
||||
|
||||
use OpenAPI\Server\Configuration;
|
||||
use OpenAPI\Server\ApiClient;
|
||||
use OpenAPI\Server\ApiException;
|
||||
use OpenAPI\Server\ObjectSerializer;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* @package OpenAPI\Server\Tests\Api
|
||||
* @author openapi-generator contributors
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPI\Server\Api\UserApiInterface
|
||||
*/
|
||||
class UserApiInterfaceTest extends WebTestCase
|
||||
{
|
||||
@@ -85,13 +82,14 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Create user.
|
||||
*
|
||||
*/
|
||||
public function testCreateUser()
|
||||
public function testCreateUser(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/user';
|
||||
|
||||
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for createUser not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,13 +98,14 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Creates list of users with given input array.
|
||||
*
|
||||
*/
|
||||
public function testCreateUsersWithArrayInput()
|
||||
public function testCreateUsersWithArrayInput(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/user/createWithArray';
|
||||
|
||||
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for createUsersWithArrayInput not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,13 +114,14 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Creates list of users with given input array.
|
||||
*
|
||||
*/
|
||||
public function testCreateUsersWithListInput()
|
||||
public function testCreateUsersWithListInput(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/user/createWithList';
|
||||
|
||||
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for createUsersWithListInput not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Delete user.
|
||||
*
|
||||
*/
|
||||
public function testDeleteUser()
|
||||
public function testDeleteUser(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -140,6 +140,7 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('DELETE', $path);
|
||||
$this->markTestSkipped('Test for deleteUser not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +149,7 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Get user by user name.
|
||||
*
|
||||
*/
|
||||
public function testGetUserByName()
|
||||
public function testGetUserByName(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -158,6 +159,7 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for getUserByName not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,13 +168,14 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Logs user into the system.
|
||||
*
|
||||
*/
|
||||
public function testLoginUser()
|
||||
public function testLoginUser(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/user/login';
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for loginUser not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,13 +184,14 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Logs out current logged in user session.
|
||||
*
|
||||
*/
|
||||
public function testLogoutUser()
|
||||
public function testLogoutUser(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
$path = '/user/logout';
|
||||
|
||||
$crawler = $client->request('GET', $path);
|
||||
$this->markTestSkipped('Test for logoutUser not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +200,7 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
* Updated user.
|
||||
*
|
||||
*/
|
||||
public function testUpdateUser()
|
||||
public function testUpdateUser(): void
|
||||
{
|
||||
$client = self::$client;
|
||||
|
||||
@@ -206,13 +210,18 @@ class UserApiInterfaceTest extends WebTestCase
|
||||
$path = str_replace($pattern, $data, $path);
|
||||
|
||||
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
|
||||
$this->markTestSkipped('Test for updateUser not implemented');
|
||||
}
|
||||
|
||||
protected function genTestData($regexp)
|
||||
/**
|
||||
* @param string $regexp
|
||||
* @return mixed
|
||||
*/
|
||||
protected function genTestData(string $regexp)
|
||||
{
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
|
||||
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$ast = $compiler->parse($regexp);
|
||||
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
|
||||
|
||||
return $generator->visit($ast);
|
||||
|
||||
Reference in New Issue
Block a user