Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[php-slim4] Partial generation #11069

Merged
merged 2 commits into from
Dec 17, 2021

Conversation

ybelenko
Copy link
Contributor

@ybelenko ybelenko commented Dec 8, 2021

Part generation of server PHP Slim4.
Closes #9573

I will add results of different generations in comments below to make it more readable.

cc @jebentier, @dkarlovi, @mandrean, @jfastnacht, @ackintosh, @renepardon

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@ybelenko
Copy link
Contributor Author

ybelenko commented Dec 8, 2021

With --global-property modelTests=false --global-property apiTests=false changes:

git diff --name-status samples/server/petstore/php-slim4
M       samples/server/petstore/php-slim4/.openapi-generator/FILES
M       samples/server/petstore/php-slim4/README.md
M       samples/server/petstore/php-slim4/composer.json
D       samples/server/petstore/php-slim4/phpunit.xml.dist
D       samples/server/petstore/php-slim4/tests/Api/PetApiTest.php
D       samples/server/petstore/php-slim4/tests/Api/StoreApiTest.php
D       samples/server/petstore/php-slim4/tests/Api/UserApiTest.php
D       samples/server/petstore/php-slim4/tests/BaseModelTest.php
D       samples/server/petstore/php-slim4/tests/Model/ApiResponseTest.php
D       samples/server/petstore/php-slim4/tests/Model/CategoryTest.php
D       samples/server/petstore/php-slim4/tests/Model/OrderTest.php
D       samples/server/petstore/php-slim4/tests/Model/PetTest.php
D       samples/server/petstore/php-slim4/tests/Model/TagTest.php
D       samples/server/petstore/php-slim4/tests/Model/UserTest.php
git diff --diff-filter=M samples/server/petstore/php-slim4
diff --git a/samples/server/petstore/php-slim4/.openapi-generator/FILES b/samples/server/petstore/php-slim4/.openapi-generator/FILES
index bfc03d5d6c..5d27377807 100644
--- a/samples/server/petstore/php-slim4/.openapi-generator/FILES
+++ b/samples/server/petstore/php-slim4/.openapi-generator/FILES
@@ -18,16 +18,5 @@ lib/Model/Tag.php
 lib/Model/User.php
 lib/SlimRouter.php
 phpcs.xml.dist
-phpunit.xml.dist
 public/.htaccess
 public/index.php
-tests/Api/PetApiTest.php
-tests/Api/StoreApiTest.php
-tests/Api/UserApiTest.php
-tests/BaseModelTest.php
-tests/Model/ApiResponseTest.php
-tests/Model/CategoryTest.php
-tests/Model/OrderTest.php
-tests/Model/PetTest.php
-tests/Model/TagTest.php
-tests/Model/UserTest.php
diff --git a/samples/server/petstore/php-slim4/README.md b/samples/server/petstore/php-slim4/README.md
index ac51de45d1..0b248f4331 100644
--- a/samples/server/petstore/php-slim4/README.md
+++ b/samples/server/petstore/php-slim4/README.md
@@ -35,22 +35,6 @@ $ php -S localhost:8888 -t php-slim-server/public
 > It may also be useful for testing purposes or for application demonstrations that are run in controlled environments.
 > It is not intended to be a full-featured web server. It should not be used on a public network.
 
-## Tests
-
-### PHPUnit
-
-This package uses PHPUnit 8 or 9(depends from your PHP version) for unit testing.
-[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
-
-Command | Target
----- | ----
-`$ composer test` | All tests
-`$ composer test-apis` | Apis tests
-`$ composer test-models` | Models tests
-
 #### Config
 
 Package contains fully functional config `./phpunit.xml.dist` file. Create `./phpunit.xml` in root folder to override it.
diff --git a/samples/server/petstore/php-slim4/composer.json b/samples/server/petstore/php-slim4/composer.json
index 529f8f9371..863922a5f4 100644
--- a/samples/server/petstore/php-slim4/composer.json
+++ b/samples/server/petstore/php-slim4/composer.json
@@ -16,7 +16,6 @@
     "slim/psr7": "^1.1.0"
   },
   "require-dev": {
-    "phpunit/phpunit": "^8.0 || ^9.0",
     "overtrue/phplint": "^2.0.2",
     "squizlabs/php_codesniffer": "^3.5"
   },
@@ -30,11 +29,6 @@
     "psr-4": { "OpenAPIServer\\": "tests/" }
   },
   "scripts": {
-    "test": [
-      "phpunit"
-    ],
-    "test-apis": "phpunit --testsuite Apis",
-    "test-models": "phpunit --testsuite Models",
     "phpcs": "phpcs",
     "phplint": "phplint ./ --exclude=vendor"
   }

@ybelenko
Copy link
Contributor Author

ybelenko commented Dec 8, 2021

With --global-property apiTests=false changes:

git diff --name-status samples/server/petstore/php-slim4
M       samples/server/petstore/php-slim4/.openapi-generator/FILES
M       samples/server/petstore/php-slim4/README.md
M       samples/server/petstore/php-slim4/composer.json
M       samples/server/petstore/php-slim4/phpunit.xml.dist
D       samples/server/petstore/php-slim4/tests/Api/PetApiTest.php
D       samples/server/petstore/php-slim4/tests/Api/StoreApiTest.php
D       samples/server/petstore/php-slim4/tests/Api/UserApiTest.php
git diff --diff-filter=M samples/server/petstore/php-slim4
diff --git a/samples/server/petstore/php-slim4/.openapi-generator/FILES b/samples/server/petstore/php-slim4/.openapi-generator/FILES
index bfc03d5d6c..2466cd67db 100644
--- a/samples/server/petstore/php-slim4/.openapi-generator/FILES
+++ b/samples/server/petstore/php-slim4/.openapi-generator/FILES
@@ -21,9 +21,6 @@ phpcs.xml.dist
 phpunit.xml.dist
 public/.htaccess
 public/index.php
-tests/Api/PetApiTest.php
-tests/Api/StoreApiTest.php
-tests/Api/UserApiTest.php
 tests/BaseModelTest.php
 tests/Model/ApiResponseTest.php
 tests/Model/CategoryTest.php
diff --git a/samples/server/petstore/php-slim4/README.md b/samples/server/petstore/php-slim4/README.md
index ac51de45d1..0d348410d4 100644
--- a/samples/server/petstore/php-slim4/README.md
+++ b/samples/server/petstore/php-slim4/README.md
@@ -48,7 +48,6 @@ How to write tests read at [2. Writing Tests for PHPUnit - PHPUnit 8.5 Manual](h
 Command | Target
 ---- | ----
 `$ composer test` | All tests
-`$ composer test-apis` | Apis tests
 `$ composer test-models` | Models tests
 
 #### Config
diff --git a/samples/server/petstore/php-slim4/composer.json b/samples/server/petstore/php-slim4/composer.json
index 529f8f9371..ca7dfef395 100644
--- a/samples/server/petstore/php-slim4/composer.json
+++ b/samples/server/petstore/php-slim4/composer.json
@@ -33,7 +33,6 @@
     "test": [
       "phpunit"
     ],
-    "test-apis": "phpunit --testsuite Apis",
     "test-models": "phpunit --testsuite Models",
     "phpcs": "phpcs",
     "phplint": "phplint ./ --exclude=vendor"
diff --git a/samples/server/petstore/php-slim4/phpunit.xml.dist b/samples/server/petstore/php-slim4/phpunit.xml.dist
index d5f76a3c64..8ef7ccca30 100644
--- a/samples/server/petstore/php-slim4/phpunit.xml.dist
+++ b/samples/server/petstore/php-slim4/phpunit.xml.dist
@@ -8,9 +8,6 @@
     </include>
   </coverage>
   <testsuites>
-    <testsuite name="Apis">
-      <directory>./tests/Api</directory>
-    </testsuite>
     <testsuite name="Models">
       <file>./tests/BaseModelTest.php</file>
       <directory>./tests/Model</directory>

@ybelenko
Copy link
Contributor Author

ybelenko commented Dec 8, 2021

With --global-property modelTests=false changes:

git diff --name-status samples/server/petstore/php-slim4
M       samples/server/petstore/php-slim4/.openapi-generator/FILES
M       samples/server/petstore/php-slim4/README.md
M       samples/server/petstore/php-slim4/composer.json
M       samples/server/petstore/php-slim4/phpunit.xml.dist
D       samples/server/petstore/php-slim4/tests/BaseModelTest.php
D       samples/server/petstore/php-slim4/tests/Model/ApiResponseTest.php
D       samples/server/petstore/php-slim4/tests/Model/CategoryTest.php
D       samples/server/petstore/php-slim4/tests/Model/OrderTest.php
D       samples/server/petstore/php-slim4/tests/Model/PetTest.php
D       samples/server/petstore/php-slim4/tests/Model/TagTest.php
D       samples/server/petstore/php-slim4/tests/Model/UserTest.php
git diff --diff-filter=M samples/server/petstore/php-slim4
diff --git a/samples/server/petstore/php-slim4/.openapi-generator/FILES b/samples/server/petstore/php-slim4/.openapi-generator/FILES
index bfc03d5d6c..84e2d01baa 100644
--- a/samples/server/petstore/php-slim4/.openapi-generator/FILES
+++ b/samples/server/petstore/php-slim4/.openapi-generator/FILES
@@ -24,10 +24,3 @@ public/index.php
 tests/Api/PetApiTest.php
 tests/Api/StoreApiTest.php
 tests/Api/UserApiTest.php
-tests/BaseModelTest.php
-tests/Model/ApiResponseTest.php
-tests/Model/CategoryTest.php
-tests/Model/OrderTest.php
-tests/Model/PetTest.php
-tests/Model/TagTest.php
-tests/Model/UserTest.php
diff --git a/samples/server/petstore/php-slim4/README.md b/samples/server/petstore/php-slim4/README.md
index ac51de45d1..397456fd3e 100644
--- a/samples/server/petstore/php-slim4/README.md
+++ b/samples/server/petstore/php-slim4/README.md
@@ -49,7 +49,6 @@ Command | Target
 ---- | ----
 `$ composer test` | All tests
 `$ composer test-apis` | Apis tests
-`$ composer test-models` | Models tests
 
 #### Config
 
diff --git a/samples/server/petstore/php-slim4/composer.json b/samples/server/petstore/php-slim4/composer.json
index 529f8f9371..677a19941d 100644
--- a/samples/server/petstore/php-slim4/composer.json
+++ b/samples/server/petstore/php-slim4/composer.json
@@ -34,7 +34,6 @@
       "phpunit"
     ],
     "test-apis": "phpunit --testsuite Apis",
-    "test-models": "phpunit --testsuite Models",
     "phpcs": "phpcs",
     "phplint": "phplint ./ --exclude=vendor"
   }
diff --git a/samples/server/petstore/php-slim4/phpunit.xml.dist b/samples/server/petstore/php-slim4/phpunit.xml.dist
index d5f76a3c64..0b8ec2d5a1 100644
--- a/samples/server/petstore/php-slim4/phpunit.xml.dist
+++ b/samples/server/petstore/php-slim4/phpunit.xml.dist
@@ -11,10 +11,6 @@
     <testsuite name="Apis">
       <directory>./tests/Api</directory>
     </testsuite>
-    <testsuite name="Models">
-      <file>./tests/BaseModelTest.php</file>
-      <directory>./tests/Model</directory>
-    </testsuite>
   </testsuites>
   <php>
     <ini name="error_reporting" value="E_ALL"/>

@ybelenko
Copy link
Contributor Author

ybelenko commented Dec 8, 2021

There is an CI error about uncommitted changes. I don't know why bin/utils/ensure-up-to-date script doesn't clean all samples folder(tests folder always untouched) before generation.

@wing328
Copy link
Member

wing328 commented Dec 14, 2021

tests folder always untouched

bin/utils/ensure-up-to-date won't purge/clean the test folders as the folder may contain manually written tests.

@ybelenko
Copy link
Contributor Author

tests folder always untouched

bin/utils/ensure-up-to-date won't purge/clean the test folders as the folder may contain manually written tests.

Slim4 doesn't contain manually written tests in the repo. How should I commit changes of generated tests if CI pipe will always reject them???

@wing328
Copy link
Member

wing328 commented Dec 15, 2021

If you're sure there's no manually written test cases, then just manually purge the folder and then regenerate the files.

@ybelenko
Copy link
Contributor Author

If you're sure there's no manually written test cases, then just manually purge the folder and then regenerate the files.

That's what I usually do, then I commit updated samples from tests folder. But this repo script doesn't and CI pipe will complain about uncommitted changes each PR. Talking about CI tests, git diff won't match.

@ybelenko
Copy link
Contributor Author

However, CI pipe complains about samples/server/petstore/php-slim4/.openapi-generator/FILES file only, like it doesn't check changes in tests folder at all. That's also weird. Anyway, we should discuss pipe Samples up-to-date in another topic. Please, review and merge, it really slows me down.

I forgot to update tests folder in latest PR. Fixing my mistake.
@ybelenko ybelenko force-pushed the 9573_php_slim4_part_generation branch from e51d704 to 07d819d Compare December 17, 2021 08:02
@wing328 wing328 merged commit d65bf8d into OpenAPITools:master Dec 17, 2021
@ybelenko ybelenko deleted the 9573_php_slim4_part_generation branch December 17, 2021 08:19
@wing328 wing328 added this to the 5.3.1 milestone Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQ][php-slim4] Partial generation support
2 participants