diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java index 23a9de74337..727822a0254 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java @@ -57,6 +57,10 @@ public class PhpSlim4ServerCodegen extends AbstractPhpCodegen { public PhpSlim4ServerCodegen() { super(); + // PDS skeleton recommends tests folder + // https://github.com/php-pds/skeleton + this.testBasePath = "tests"; + modifyFeatureSet(features -> features .includeDocumentationFeatures(DocumentationFeature.Readme) .wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML)) @@ -203,8 +207,8 @@ public class PhpSlim4ServerCodegen extends AbstractPhpCodegen { supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json")); - supportingFiles.add(new SupportingFile("index.mustache", "", "index.php")); - supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess")); + supportingFiles.add(new SupportingFile("index.mustache", "public", "index.php")); + supportingFiles.add(new SupportingFile(".htaccess", "public", ".htaccess")); supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php")); supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist")); supportingFiles.add(new SupportingFile("phpcs.xml.mustache", "", "phpcs.xml.dist")); diff --git a/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache b/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache index cf43fdd7bac..7a1e9c03d4f 100644 --- a/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache @@ -38,9 +38,9 @@ Application requires at least one config file(`config/dev/config.inc.php` or `co ## Start devserver -Run the following command in terminal to start localhost web server, assuming `./php-slim-server/` is public-accessible directory with `index.php` file: +Run the following command in terminal to start localhost web server, assuming `./php-slim-server/public/` is public-accessible directory with `index.php` file: ```bash -$ php -S localhost:8888 -t php-slim-server +$ php -S localhost:8888 -t php-slim-server/public ``` > **Warning** This web server was designed to aid application development. > It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. diff --git a/modules/openapi-generator/src/main/resources/php-slim4-server/index.mustache b/modules/openapi-generator/src/main/resources/php-slim4-server/index.mustache index 4b3cfcaeecb..66f3962685e 100644 --- a/modules/openapi-generator/src/main/resources/php-slim4-server/index.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim4-server/index.mustache @@ -7,7 +7,7 @@ * https://github.com/openapitools/openapi-generator */{{#apiInfo}} -require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; use {{invokerPackage}}\SlimRouter; use Psr\Http\Message\ServerRequestInterface; @@ -17,9 +17,9 @@ use OpenAPIServer\Mock\OpenApiDataMocker; // load config file $config = []; -if (is_array($prodConfig = @include(__DIR__ . '/config/prod/config.inc.php'))) { +if (is_array($prodConfig = @include(__DIR__ . '/../config/prod/config.inc.php'))) { $config = $prodConfig; -} elseif (is_array($devConfig = @include(__DIR__ . '/config/dev/config.inc.php'))) { +} elseif (is_array($devConfig = @include(__DIR__ . '/../config/dev/config.inc.php'))) { $config = $devConfig; } else { throw new InvalidArgumentException('Config file missed or broken.'); diff --git a/samples/server/petstore/php-slim4/.openapi-generator/FILES b/samples/server/petstore/php-slim4/.openapi-generator/FILES index 6d7926cf510..8bd8c2bae33 100644 --- a/samples/server/petstore/php-slim4/.openapi-generator/FILES +++ b/samples/server/petstore/php-slim4/.openapi-generator/FILES @@ -1,11 +1,9 @@ .gitignore -.htaccess README.md composer.json config/.htaccess config/dev/example.inc.php config/prod/example.inc.php -index.php lib/Api/AbstractPetApi.php lib/Api/AbstractStoreApi.php lib/Api/AbstractUserApi.php @@ -39,4 +37,6 @@ lib/Model/User.php lib/SlimRouter.php phpcs.xml.dist phpunit.xml.dist -test/BaseModelTest.php +public/.htaccess +public/index.php +tests/BaseModelTest.php diff --git a/samples/server/petstore/php-slim4/README.md b/samples/server/petstore/php-slim4/README.md index 3f5c820198c..b055cfb62bc 100644 --- a/samples/server/petstore/php-slim4/README.md +++ b/samples/server/petstore/php-slim4/README.md @@ -27,9 +27,9 @@ Application requires at least one config file(`config/dev/config.inc.php` or `co ## Start devserver -Run the following command in terminal to start localhost web server, assuming `./php-slim-server/` is public-accessible directory with `index.php` file: +Run the following command in terminal to start localhost web server, assuming `./php-slim-server/public/` is public-accessible directory with `index.php` file: ```bash -$ php -S localhost:8888 -t php-slim-server +$ php -S localhost:8888 -t php-slim-server/public ``` > **Warning** This web server was designed to aid application development. > It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. @@ -40,7 +40,7 @@ $ php -S localhost:8888 -t php-slim-server ### PHPUnit This package uses PHPUnit 8 or 9(depends from your PHP version) for unit testing. -[Test folder](test) contains templates which you can fill with real test assertions. +[Test folder](tests) contains templates which you can fill with real test assertions. How to write tests read at [2. Writing Tests for PHPUnit - PHPUnit 8.5 Manual](https://phpunit.readthedocs.io/en/8.5/writing-tests-for-phpunit.html). #### Run diff --git a/samples/server/petstore/php-slim4/composer.json b/samples/server/petstore/php-slim4/composer.json index 8181c11ae83..085da3886de 100644 --- a/samples/server/petstore/php-slim4/composer.json +++ b/samples/server/petstore/php-slim4/composer.json @@ -27,7 +27,7 @@ ]} }, "autoload-dev": { - "psr-4": { "OpenAPIServer\\": "test/" } + "psr-4": { "OpenAPIServer\\": "tests/" } }, "scripts": { "test": [ diff --git a/samples/server/petstore/php-slim4/lib/Model/InlineObject.php b/samples/server/petstore/php-slim4/lib/Model/InlineObject.php deleted file mode 100644 index 1b106e77d75..00000000000 --- a/samples/server/petstore/php-slim4/lib/Model/InlineObject.php +++ /dev/null @@ -1,60 +0,0 @@ - - ./test/Api + ./tests/Api - ./test/BaseModelTest.php - ./test/Model + ./tests/BaseModelTest.php + ./tests/Model diff --git a/samples/server/petstore/php-slim4/.htaccess b/samples/server/petstore/php-slim4/public/.htaccess similarity index 100% rename from samples/server/petstore/php-slim4/.htaccess rename to samples/server/petstore/php-slim4/public/.htaccess diff --git a/samples/server/petstore/php-slim4/index.php b/samples/server/petstore/php-slim4/public/index.php similarity index 88% rename from samples/server/petstore/php-slim4/index.php rename to samples/server/petstore/php-slim4/public/index.php index c7b0a3a0a4b..663ed396242 100644 --- a/samples/server/petstore/php-slim4/index.php +++ b/samples/server/petstore/php-slim4/public/index.php @@ -20,7 +20,7 @@ * https://github.com/openapitools/openapi-generator */ -require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; use OpenAPIServer\SlimRouter; use Psr\Http\Message\ServerRequestInterface; @@ -29,9 +29,9 @@ use OpenAPIServer\Mock\OpenApiDataMocker; // load config file $config = []; -if (is_array($prodConfig = @include(__DIR__ . '/config/prod/config.inc.php'))) { +if (is_array($prodConfig = @include(__DIR__ . '/../config/prod/config.inc.php'))) { $config = $prodConfig; -} elseif (is_array($devConfig = @include(__DIR__ . '/config/dev/config.inc.php'))) { +} elseif (is_array($devConfig = @include(__DIR__ . '/../config/dev/config.inc.php'))) { $config = $devConfig; } else { throw new InvalidArgumentException('Config file missed or broken.'); diff --git a/samples/server/petstore/php-slim4/test/Model/InlineObject1Test.php b/samples/server/petstore/php-slim4/test/Model/InlineObject1Test.php deleted file mode 100644 index c70074021a0..00000000000 --- a/samples/server/petstore/php-slim4/test/Model/InlineObject1Test.php +++ /dev/null @@ -1,114 +0,0 @@ -assertSame('\\' . InlineObject1::class, $namespacedClassname); - $this->assertTrue( - class_exists($namespacedClassname), - sprintf('Assertion failed that "%s" class exists', $namespacedClassname) - ); - $this->markTestIncomplete( - 'Test of "InlineObject1" model has not been implemented yet.' - ); - } - - /** - * Test attribute "additionalMetadata" - */ - public function testPropertyAdditionalMetadata() - { - $this->markTestIncomplete( - 'Test of "additionalMetadata" property in "InlineObject1" model has not been implemented yet.' - ); - } - - /** - * Test attribute "file" - */ - public function testPropertyFile() - { - $this->markTestIncomplete( - 'Test of "file" property in "InlineObject1" model has not been implemented yet.' - ); - } - - /** - * Test getOpenApiSchema static method - * @covers ::getOpenApiSchema - */ - public function testGetOpenApiSchema() - { - $schemaArr = InlineObject1::getOpenApiSchema(); - $this->assertIsArray($schemaArr); - } -} diff --git a/samples/server/petstore/php-slim4/test/Model/InlineObjectTest.php b/samples/server/petstore/php-slim4/test/Model/InlineObjectTest.php deleted file mode 100644 index 0651084a62d..00000000000 --- a/samples/server/petstore/php-slim4/test/Model/InlineObjectTest.php +++ /dev/null @@ -1,114 +0,0 @@ -assertSame('\\' . InlineObject::class, $namespacedClassname); - $this->assertTrue( - class_exists($namespacedClassname), - sprintf('Assertion failed that "%s" class exists', $namespacedClassname) - ); - $this->markTestIncomplete( - 'Test of "InlineObject" model has not been implemented yet.' - ); - } - - /** - * Test attribute "name" - */ - public function testPropertyName() - { - $this->markTestIncomplete( - 'Test of "name" property in "InlineObject" model has not been implemented yet.' - ); - } - - /** - * Test attribute "status" - */ - public function testPropertyStatus() - { - $this->markTestIncomplete( - 'Test of "status" property in "InlineObject" model has not been implemented yet.' - ); - } - - /** - * Test getOpenApiSchema static method - * @covers ::getOpenApiSchema - */ - public function testGetOpenApiSchema() - { - $schemaArr = InlineObject::getOpenApiSchema(); - $this->assertIsArray($schemaArr); - } -} diff --git a/samples/server/petstore/php-slim4/test/Api/PetApiTest.php b/samples/server/petstore/php-slim4/tests/Api/PetApiTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Api/PetApiTest.php rename to samples/server/petstore/php-slim4/tests/Api/PetApiTest.php diff --git a/samples/server/petstore/php-slim4/test/Api/StoreApiTest.php b/samples/server/petstore/php-slim4/tests/Api/StoreApiTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Api/StoreApiTest.php rename to samples/server/petstore/php-slim4/tests/Api/StoreApiTest.php diff --git a/samples/server/petstore/php-slim4/test/Api/UserApiTest.php b/samples/server/petstore/php-slim4/tests/Api/UserApiTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Api/UserApiTest.php rename to samples/server/petstore/php-slim4/tests/Api/UserApiTest.php diff --git a/samples/server/petstore/php-slim4/test/BaseModelTest.php b/samples/server/petstore/php-slim4/tests/BaseModelTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/BaseModelTest.php rename to samples/server/petstore/php-slim4/tests/BaseModelTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/ApiResponseTest.php b/samples/server/petstore/php-slim4/tests/Model/ApiResponseTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/ApiResponseTest.php rename to samples/server/petstore/php-slim4/tests/Model/ApiResponseTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/CategoryTest.php b/samples/server/petstore/php-slim4/tests/Model/CategoryTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/CategoryTest.php rename to samples/server/petstore/php-slim4/tests/Model/CategoryTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/OrderTest.php b/samples/server/petstore/php-slim4/tests/Model/OrderTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/OrderTest.php rename to samples/server/petstore/php-slim4/tests/Model/OrderTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/PetTest.php b/samples/server/petstore/php-slim4/tests/Model/PetTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/PetTest.php rename to samples/server/petstore/php-slim4/tests/Model/PetTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/TagTest.php b/samples/server/petstore/php-slim4/tests/Model/TagTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/TagTest.php rename to samples/server/petstore/php-slim4/tests/Model/TagTest.php diff --git a/samples/server/petstore/php-slim4/test/Model/UserTest.php b/samples/server/petstore/php-slim4/tests/Model/UserTest.php similarity index 100% rename from samples/server/petstore/php-slim4/test/Model/UserTest.php rename to samples/server/petstore/php-slim4/tests/Model/UserTest.php