From 098025d61fb3490f3e773f6ca0dad3054d4c2bdd Mon Sep 17 00:00:00 2001 From: sspat Date: Mon, 11 Apr 2022 14:48:15 +0300 Subject: [PATCH] Prepare new release (#170) * Prepare new release * fix tests * Fix tests * fix tests * fix tests --- README.md | 15 ++++++- test/functional/Command/CommandTestCase.php | 39 ++++++++---------- .../Controller/ApiControllerTest.php | 40 +++++++++---------- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 8abe7cfd..9272e908 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,23 @@ All you have to do is to implement the API call handler interfaces and return th The preferred way to install this extension is through [composer](http://getcomposer.org/download/). +The following workaround with a forked version of `cebe/php-openapi` will be used until a version of it +compatible with php 8.1 will be released: + +Add to your composer.json +``` +"repositories": [ + { + "type": "vcs", + "url": "https://github.com/onmoon/php-openapi" + } +], +``` + Run ``` -composer require onmoon/openapi-server-bundle +composer require cebe/php-openapi:dev-php-81-compat onmoon/openapi-server-bundle ``` Then add the bundle class to your `config/bundles.php`: diff --git a/test/functional/Command/CommandTestCase.php b/test/functional/Command/CommandTestCase.php index 0b13d351..6a5344f4 100644 --- a/test/functional/Command/CommandTestCase.php +++ b/test/functional/Command/CommandTestCase.php @@ -10,10 +10,9 @@ use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use function get_class; - abstract class CommandTestCase extends KernelTestCase { protected string $openapiNamespace = 'PetStore'; @@ -21,26 +20,6 @@ abstract class CommandTestCase extends KernelTestCase protected CommandTester $commandTester; protected Application $application; - /** - * @param mixed[] $data - */ - public function __construct(?string $name = null, array $data = [], string $dataName = '') - { - parent::__construct($name, $data, $dataName); - - $kernelClass = new class ('test', true) extends TestKernel { - protected function configureContainer(ContainerConfigurator $c): void - { - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - } - }; - - self::$class = get_class($kernelClass); - } - public function setUp(): void { $this->application = new Application(self::bootKernel()); @@ -53,4 +32,20 @@ public function tearDown(): void unset($this->commandTester, $this->application); parent::tearDown(); } + + /** + * {@inheritDoc} + */ + protected static function createKernel(array $options = []): KernelInterface + { + return new class ('test', true) extends TestKernel { + protected function configureContainer(ContainerConfigurator $c): void + { + } + + protected function configureRoutes(RoutingConfigurator $routes): void + { + } + }; + } } diff --git a/test/functional/Controller/ApiControllerTest.php b/test/functional/Controller/ApiControllerTest.php index 26eb9b9c..c4864f20 100644 --- a/test/functional/Controller/ApiControllerTest.php +++ b/test/functional/Controller/ApiControllerTest.php @@ -17,9 +17,9 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use function get_class; use function Safe\file_put_contents; use function Safe\json_decode; @@ -30,27 +30,6 @@ class ApiControllerTest extends WebTestCase { private AbstractBrowser $client; - /** - * @param mixed[] $data - */ - public function __construct(?string $name = null, array $data = [], string $dataName = '') - { - parent::__construct($name, $data, $dataName); - - $kernelClass = new class ('test', true) extends TestKernel { - protected function configureContainer(ContainerConfigurator $c): void - { - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - $routes->import(__DIR__ . '/openapi_routes.yaml'); - } - }; - - self::$class = get_class($kernelClass); - } - public function setUp(): void { /** @var HttpBrowser $client */ @@ -100,6 +79,23 @@ public function testGetApiReturnsOkRequest(): void Assert::assertEquals(['title' => 'test'], json_decode((string) $response->getContent(), true)); } + /** + * {@inheritDoc} + */ + protected static function createKernel(array $options = []): KernelInterface + { + return new class ('test', true) extends TestKernel { + protected function configureContainer(ContainerConfigurator $c): void + { + } + + protected function configureRoutes(RoutingConfigurator $routes): void + { + $routes->import(__DIR__ . '/openapi_routes.yaml'); + } + }; + } + private function createGetGoodImpl(): string { $content = <<