Skip to content

Commit

Permalink
Prepare new release (#170)
Browse files Browse the repository at this point in the history
* Prepare new release

* fix tests

* Fix tests

* fix tests

* fix tests
  • Loading branch information
sspat authored Apr 11, 2022
1 parent 5c7809a commit 098025d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 45 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
39 changes: 17 additions & 22 deletions test/functional/Command/CommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,16 @@
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';
protected string $openapiOperationId = 'getGood';
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());
Expand All @@ -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
{
}
};
}
}
40 changes: 18 additions & 22 deletions test/functional/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 */
Expand Down Expand Up @@ -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 = <<<EOD
Expand Down

0 comments on commit 098025d

Please sign in to comment.