From 47da03b578d69e7bc43f9926abeb55691d019b37 Mon Sep 17 00:00:00 2001 From: Ms_Natali Date: Fri, 24 May 2024 16:00:21 +0300 Subject: [PATCH 1/3] ENSITECH-74 --- .../post-checkout/01-install-dependencies.sh | 1 + .../post-merge/01-install-dependencies.sh | 1 + .git_hooks/post-merge/install-dependecies.sh | 16 ---- .git_hooks/pre-commit/01-lint-php.sh | 1 + .git_hooks/pre-commit/02-php-cs-fixer.sh | 1 + .git_hooks/pre-push/01-composer-validate.sh | 1 + .git_hooks/pre-push/02-phpstan.sh | 1 + .git_hooks/pre-push/03-test-code.sh | 1 + .git_hooks/pre-push/var-dump-checker.sh | 21 ----- .../composer-validate.sh | 4 +- .../install-dependencies.sh} | 8 +- .../{pre-commit => scripts}/lint-php.sh | 8 +- .../{pre-commit => scripts}/php-cs-fixer.sh | 2 + .git_hooks/scripts/phpstan.sh | 20 +++++ .git_hooks/scripts/test-code.sh | 20 +++++ .github/CONTRIBUTING.md | 2 - .github/workflows/run-tests.yml | 24 +++--- .gitignore | 86 ++++++++++++++++++- .php-cs-fixer.php | 4 +- CONTRIBUTING.md | 55 ------------ LICENSE.md | 77 +++++++++++++++-- README.md | 22 ++++- composer.json | 36 ++++---- phpstan-package.neon | 0 phpstan.neon.dist | 61 +++++++++++++ phpunit.xml | 12 +-- src/CachedValidator.php | 2 +- src/ValidatesAgainstOpenApiSpec.php | 4 +- tests/Pest.php | 19 ++-- tests/TestCase.php | 9 ++ 30 files changed, 353 insertions(+), 166 deletions(-) create mode 120000 .git_hooks/post-checkout/01-install-dependencies.sh create mode 120000 .git_hooks/post-merge/01-install-dependencies.sh delete mode 100755 .git_hooks/post-merge/install-dependecies.sh create mode 120000 .git_hooks/pre-commit/01-lint-php.sh create mode 120000 .git_hooks/pre-commit/02-php-cs-fixer.sh create mode 120000 .git_hooks/pre-push/01-composer-validate.sh create mode 120000 .git_hooks/pre-push/02-phpstan.sh create mode 120000 .git_hooks/pre-push/03-test-code.sh delete mode 100755 .git_hooks/pre-push/var-dump-checker.sh rename .git_hooks/{pre-push => scripts}/composer-validate.sh (91%) rename .git_hooks/{post-checkout/install-dependecies.sh => scripts/install-dependencies.sh} (53%) rename .git_hooks/{pre-commit => scripts}/lint-php.sh (94%) rename .git_hooks/{pre-commit => scripts}/php-cs-fixer.sh (97%) create mode 100755 .git_hooks/scripts/phpstan.sh create mode 100755 .git_hooks/scripts/test-code.sh delete mode 100644 CONTRIBUTING.md create mode 100644 phpstan-package.neon create mode 100644 phpstan.neon.dist create mode 100644 tests/TestCase.php diff --git a/.git_hooks/post-checkout/01-install-dependencies.sh b/.git_hooks/post-checkout/01-install-dependencies.sh new file mode 120000 index 0000000..43a65ea --- /dev/null +++ b/.git_hooks/post-checkout/01-install-dependencies.sh @@ -0,0 +1 @@ +../scripts/install-dependencies.sh \ No newline at end of file diff --git a/.git_hooks/post-merge/01-install-dependencies.sh b/.git_hooks/post-merge/01-install-dependencies.sh new file mode 120000 index 0000000..43a65ea --- /dev/null +++ b/.git_hooks/post-merge/01-install-dependencies.sh @@ -0,0 +1 @@ +../scripts/install-dependencies.sh \ No newline at end of file diff --git a/.git_hooks/post-merge/install-dependecies.sh b/.git_hooks/post-merge/install-dependecies.sh deleted file mode 100755 index 7bd6a9c..0000000 --- a/.git_hooks/post-merge/install-dependecies.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -ESC_SEQ="\x1b[" -COL_RESET=$ESC_SEQ"39;49;00m" -COL_RED=$ESC_SEQ"0;31m" -COL_GREEN=$ESC_SEQ"0;32m" -COL_YELLOW=$ESC_SEQ"0;33m" - -changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" - -check_run() { - echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" -} - -check_run composer.lock "composer install" -exit 0 diff --git a/.git_hooks/pre-commit/01-lint-php.sh b/.git_hooks/pre-commit/01-lint-php.sh new file mode 120000 index 0000000..5833040 --- /dev/null +++ b/.git_hooks/pre-commit/01-lint-php.sh @@ -0,0 +1 @@ +../scripts/lint-php.sh \ No newline at end of file diff --git a/.git_hooks/pre-commit/02-php-cs-fixer.sh b/.git_hooks/pre-commit/02-php-cs-fixer.sh new file mode 120000 index 0000000..66c2032 --- /dev/null +++ b/.git_hooks/pre-commit/02-php-cs-fixer.sh @@ -0,0 +1 @@ +../scripts/php-cs-fixer.sh \ No newline at end of file diff --git a/.git_hooks/pre-push/01-composer-validate.sh b/.git_hooks/pre-push/01-composer-validate.sh new file mode 120000 index 0000000..61e981f --- /dev/null +++ b/.git_hooks/pre-push/01-composer-validate.sh @@ -0,0 +1 @@ +../scripts/composer-validate.sh \ No newline at end of file diff --git a/.git_hooks/pre-push/02-phpstan.sh b/.git_hooks/pre-push/02-phpstan.sh new file mode 120000 index 0000000..05c8a9b --- /dev/null +++ b/.git_hooks/pre-push/02-phpstan.sh @@ -0,0 +1 @@ +../scripts/phpstan.sh \ No newline at end of file diff --git a/.git_hooks/pre-push/03-test-code.sh b/.git_hooks/pre-push/03-test-code.sh new file mode 120000 index 0000000..b33ab89 --- /dev/null +++ b/.git_hooks/pre-push/03-test-code.sh @@ -0,0 +1 @@ +../scripts/test-code.sh \ No newline at end of file diff --git a/.git_hooks/pre-push/var-dump-checker.sh b/.git_hooks/pre-push/var-dump-checker.sh deleted file mode 100755 index 167b6b4..0000000 --- a/.git_hooks/pre-push/var-dump-checker.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -ESC_SEQ="\x1b[" -COL_RESET=$ESC_SEQ"39;49;00m" -COL_RED=$ESC_SEQ"0;31m" -COL_GREEN=$ESC_SEQ"0;32m" -COL_YELLOW=$ESC_SEQ"0;33m" - -echo -printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"var-dump-checker\"" - -./vendor/bin/var-dump-check --laravel --exclude bootstrap --exclude node_modules --exclude vendor . - -# If the grep command has no hits - echo a warning and exit with non-zero status. -if [ $? == 1 ]; then - printf "$COL_RED%s$COL_RESET\r\n\r\n" "Some var_dump usage found. Please fix your code" - exit 1 -fi - -echo "Okay" -exit 0 diff --git a/.git_hooks/pre-push/composer-validate.sh b/.git_hooks/scripts/composer-validate.sh similarity index 91% rename from .git_hooks/pre-push/composer-validate.sh rename to .git_hooks/scripts/composer-validate.sh index d6df93e..543451a 100755 --- a/.git_hooks/pre-push/composer-validate.sh +++ b/.git_hooks/scripts/composer-validate.sh @@ -1,6 +1,6 @@ #!/bin/bash -# validate composer +# Validate composer.json before commit ESC_SEQ="\x1b[" COL_RESET=$ESC_SEQ"39;49;00m" @@ -8,7 +8,7 @@ COL_RED=$ESC_SEQ"0;31m" COL_GREEN=$ESC_SEQ"0;32m" COL_YELLOW=$ESC_SEQ"0;33m" -echo +echo printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\"" VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid") diff --git a/.git_hooks/post-checkout/install-dependecies.sh b/.git_hooks/scripts/install-dependencies.sh similarity index 53% rename from .git_hooks/post-checkout/install-dependecies.sh rename to .git_hooks/scripts/install-dependencies.sh index 7bd6a9c..3b308e5 100755 --- a/.git_hooks/post-checkout/install-dependecies.sh +++ b/.git_hooks/scripts/install-dependencies.sh @@ -1,5 +1,7 @@ #!/bin/bash +# - 'composer update' if changed composer.json + ESC_SEQ="\x1b[" COL_RESET=$ESC_SEQ"39;49;00m" COL_RED=$ESC_SEQ"0;31m" @@ -9,8 +11,8 @@ COL_YELLOW=$ESC_SEQ"0;33m" changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" check_run() { - echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" + echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2" } - -check_run composer.lock "composer install" + +check_run composer.json "composer update" exit 0 diff --git a/.git_hooks/pre-commit/lint-php.sh b/.git_hooks/scripts/lint-php.sh similarity index 94% rename from .git_hooks/pre-commit/lint-php.sh rename to .git_hooks/scripts/lint-php.sh index 1c027a8..2850447 100755 --- a/.git_hooks/pre-commit/lint-php.sh +++ b/.git_hooks/scripts/lint-php.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Lint all added php-files via 'php -l' + ROOT_DIR="$(pwd)/" LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD) ERRORS_BUFFER="" @@ -31,13 +33,13 @@ do fi done if [ "$ERRORS_BUFFER" != "" ]; then - echo + echo echo "These errors were found in try-to-commit files: " echo -e $ERRORS_BUFFER - echo + echo printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first." exit 1 else echo "Okay" exit 0 -fi \ No newline at end of file +fi diff --git a/.git_hooks/pre-commit/php-cs-fixer.sh b/.git_hooks/scripts/php-cs-fixer.sh similarity index 97% rename from .git_hooks/pre-commit/php-cs-fixer.sh rename to .git_hooks/scripts/php-cs-fixer.sh index c45bc51..3fe095a 100755 --- a/.git_hooks/pre-commit/php-cs-fixer.sh +++ b/.git_hooks/scripts/php-cs-fixer.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Check code style via '.php-cs-fixer.php' + EXECUTABLE_NAME=php-cs-fixer EXECUTABLE_COMMAND=fix CONFIG_FILE=.php-cs-fixer.php diff --git a/.git_hooks/scripts/phpstan.sh b/.git_hooks/scripts/phpstan.sh new file mode 100755 index 0000000..7c15b55 --- /dev/null +++ b/.git_hooks/scripts/phpstan.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Run composer phpstan + +ESC_SEQ="\x1b[" +COL_RESET=$ESC_SEQ"39;49;00m" +COL_RED=$ESC_SEQ"0;31m" +COL_GREEN=$ESC_SEQ"0;32m" +COL_YELLOW=$ESC_SEQ"0;33m" + +echo +printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"phpstan\"" + +if composer phpstan; then + echo "Okay" + exit 0 +else + printf "$COL_RED%s$COL_RESET\r\n" "phpstan analysis failed." + exit 1 +fi diff --git a/.git_hooks/scripts/test-code.sh b/.git_hooks/scripts/test-code.sh new file mode 100755 index 0000000..faa22a1 --- /dev/null +++ b/.git_hooks/scripts/test-code.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Run composer test + +ESC_SEQ="\x1b[" +COL_RESET=$ESC_SEQ"39;49;00m" +COL_RED=$ESC_SEQ"0;31m" +COL_GREEN=$ESC_SEQ"0;32m" +COL_YELLOW=$ESC_SEQ"0;33m" + +echo +printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"test-code\"" + +if composer test; then + echo "Okay" + exit 0 +else + printf "$COL_RED%s$COL_RESET\r\n" "Tests failed." + exit 1 +fi diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ad39967..8169284 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -42,8 +42,6 @@ If the project maintainer has any additional requirements, you will find them li - **Add tests!** - Your patch won't be accepted if it doesn't have tests. -- **Use hooks!** - You can make use of .git hooks if you install them using `npm i` - - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dbe147a..f22b0e8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,17 +12,8 @@ jobs: strategy: fail-fast: true matrix: - php: [8.0, 8.1, 8.2, 8.3] - laravel: [8.*, 9.*, 10.*, 11.*] - include: - - laravel: 8.* - testbench: ^6.23 - - laravel: 9.* - testbench: 7.* - - laravel: 10.* - testbench: 8.* - - laravel: 11.* - testbench: 9.* + php: [8.1, 8.2, 8.3] + laravel: [9.*, 10.*, 11.*] exclude: - laravel: 10.* php: 8.0 @@ -51,7 +42,14 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update composer update --prefer-stable --prefer-dist --no-interaction + + - name: Composer Validate + run: ./.git_hooks/scripts/composer-validate.sh + - name: Execute tests - run: vendor/bin/pest + run: composer test-ci + + - name: Execute phpstan + run: ./.git_hooks/scripts/phpstan.sh diff --git a/.gitignore b/.gitignore index 292f20d..daa725d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,85 @@ -.idea -/vendor +# Project # +######################## +.php_cs.cache +.php-cs-fixer.cache +.huskyrc +clients/* +!clients/.gitkeep +storage/ensi +generated +studio.json +build /node_modules +/vendor +.phpunit.result.cache composer.lock +composer.local.json +Homestead.json +Homestead.yaml +npm-debug.log +yarn-error.log -*.cache -.huskyrc +# IDEs # +################### +*.sublime-project +*.sublime-workspace +/.idea +/.vscode +*.komodoproject +.vscode + +# Static content # +################### +*.csv +*.pdf +*.doc +*.docx +*.xls +*.xlsx +*.xml +!phpunit.xml +!psalm.xml +*.yml +*.txt +*.wav +*.mp3 +*.avi + +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.box + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.tgz +*.iso +*.jar +*.rar +*.tar +*.zip +*.phar + +# OS generated files # +###################### +.DS_Store +.DS_Store? +.nfs* +._* +.Spotlight-V100 +.Trashes +.vagrant +ehthumbs.db +Thumbs.db +sftp-config.json +auth.json \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 9a110fe..b9ca63e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -13,12 +13,15 @@ return (new PhpCsFixer\Config()) ->setRules([ '@PSR2' => true, + '@PSR12' => true, 'array_syntax' => ['syntax' => 'short'], 'ordered_imports' => ['sort_algorithm' => 'alpha'], 'no_unused_imports' => true, 'trailing_comma_in_multiline' => true, 'phpdoc_scalar' => true, 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'concat_space' => ['spacing' => 'one'], 'blank_line_before_statement' => [ 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], ], @@ -36,6 +39,5 @@ 'single_trait_insert_per_statement' => true, 'no_whitespace_in_blank_line' => true, 'method_chaining_indentation' => true, - ]) ->setFinder($finder); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b4ae1c4..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,55 +0,0 @@ -# Contributing - -Contributions are **welcome** and will be fully **credited**. - -Please read and understand the contribution guide before creating an issue or pull request. - -## Etiquette - -This project is open source, and as such, the maintainers give their free time to build and maintain the source code -held within. They make the code freely available in the hope that it will be of use to other developers. It would be -extremely unfair for them to suffer abuse or anger for their hard work. - -Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the -world that developers are civilized and selfless people. - -It's the duty of the maintainer to ensure that all submissions to the project are of sufficient -quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. - -## Viability - -When requesting or submitting new features, first consider whether it might be useful to others. Open -source projects are used by many developers, who may have entirely different needs to your own. Think about -whether or not your feature is likely to be used by other users of the project. - -## Procedure - -Before filing an issue: - -- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. -- Check to make sure your feature suggestion isn't already present within the project. -- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. -- Check the pull requests tab to ensure that the feature isn't already in progress. - -Before submitting a pull request: - -- Check the codebase to ensure that your feature doesn't already exist. -- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. - -## Requirements - -If the project maintainer has any additional requirements, you will find them listed here. - -- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). - -- **Add tests!** - Your patch won't be accepted if it doesn't have tests. - -- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - -- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. - -- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. - -- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. - -**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md index 572ad14..2ed94d2 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,8 +1,75 @@ -The MIT License (MIT) -Copyright (C) 2021 Ensi mail@greensight.ru +Открытая лицензия на право использования программы для ЭВМ Greensight Ecom Platform (GEP) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +1. Преамбула -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +1.1. Общество с ограниченной ответственностью «ГринСайт», в лице генерального директора Волкова Егора Владимировича, действующего на основании Устава, публикует условия публичной оферты о предоставлении открытой лицензии на право использования программы для ЭВМ Greensight Ecom Platform (GEP) (далее — Ensi) в соответствии с условиями ст. 1286.1 Гражданского кодекса РФ (далее — Оферта). -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +1.2. Правообладателем Ensi является ООО «ГринСайт» (далее — Правообладатель), в соответствии со свидетельством о государственной регистрации программы для ЭВМ № 2 020 663 096 от 22.10.2020 г. + +1.3. В соответствии с пунктом 2 статьи 437 Гражданского кодекса РФ в случае принятия изложенных в Оферте условий Правообладателя, юридическое или физическое лицо, производящее акцепт Оферты, становится лицензиатом (в соответствии с пунктом 3 статьи 438 ГК РФ акцепт оферты равносилен заключению договора на условиях, изложенных в оферте), а Правообладатель и лицензиат совместно — сторонами лицензионного договора. + +1.4. Вся документация, функциональные задания, сервисы и исходные коды Ensi размещены в сети Интернет по адресам: https://ensi.tech/ https://gitlab.com/greensight/ensi (далее — Сайт платформы). + +1.5. Правообладатель является участником проекта «Сколково» и предоставляет права использования Ensi в рамках коммерциализации результатов своих исследований и разработок по направлению «стратегические компьютерные технологии и программное обеспечение». + +2. Порядок акцепта оферты + +2.1. Лицензионный договор, заключаемый на основании акцептирования лицензиатом Оферты (далее — Лицензионный договор), является договором присоединения, к которому лицензиат присоединяется без каких-либо исключений и/или оговорок. + +2.2. Акцепт Оферты происходит в момент скачивания материалов Ensi с Сайта платформы. + +2.3. Срок акцепта Оферты не ограничен. + +3. Перечень прав использования Ensi + +3.1. При соблюдении лицензиатом требований раздела 4 Оферты, предоставляемое право использования ENSI включает в себя: + +3.1.1. Право использования Ensi на технических средствах лицензиата в соответствии с назначением Ensi, в том числе, все права использования, предусмотренные ст. 1280 Гражданского кодекса РФ; + +3.1.2. Право на воспроизведение Ensi, не ограниченное правом его инсталляции и запуска; + +3.1.3. Право на модификацию, адаптацию, внесение изменений и создание производных произведений (сложных произведений) с Ensi. + +3.2. Лицензиату предоставляется право передачи третьим лицам прав, указанных в п. 3.1 Оферты (право сублицензирования). + +3.3. Действие Лицензионного договора — территория всего мира. + +3.4. Право использования Ensi предоставляется лицензиату на весь срок действия исключительных прав Правообладателя. + +3.5. Право использования Ensi предоставляется безвозмездно. Лицензиат вправе использовать Ensi для создания производных произведений (сложных произведений) и их коммерческого применения, с учетом ограничений раздела 4 Оферты. + +4. Обязанности лицензиата + +4.1. Лицензиату предоставляются права указанные в разделе 3 Оферты при соблюдении им следующих условий: + +4.1.1. Наличия письменного указания на авторство Правообладателя и ссылки на Сайт платформы при реализации третьим лицам Ensi (в коммерческих или некоммерческих целях), а также в любых созданных производных от Ensi произведениях. + +4.1.2. Сохранения неизменным следующих частей кода Ensi: +- в файле src/pages/_app.tsx строка — <meta name="generator" content="Ensi Platform" /> +- в файле next.config.js строка — return [{ source: '/(.*)', headers: [{ key: 'X-Ensi-Platform', value: '1' }] }]; + +Удаление данных частей кода будет является существенным нарушением условий Оферты. + +4.1.3. Использования Ensi в законных целях, а именно: не нарушающих законодательство Российской Федерации, норм международных договоров Российской Федерации, общепризнанных принципов и норм международного права. Не допускается использование Ensi в проектах, противоречащих принципам гуманности и морали, в распространении материалов и информации запрещенных в Российской Федерации. + +4.2. При нарушении лицензиатом условий п. 4.1 Оферты, Правообладатель вправе в одностороннем порядке расторгнуть Лицензионный договор и потребовать мер защиты исключительных прав, включая положения ст.ст. 1252, 1301 Гражданского кодекса РФ. + +4.3. Лицензиат дает Правообладателю согласие на указание своего фирменного наименования и логотипа на сайте Платформы. Правообладатель вправе использовать фирменное наименование и логотип Лицензиата в своих маркетинговых целях без дополнительного согласования с Лицензиатом. + +5. Ограничение ответственности + +5.1. Права использования Ensi предоставляются на условии «как есть» («as is») без какого-либо вида гарантий. Правообладатель не имеет обязательств перед лицензиатом по поддержанию функционирования Ensi в случае сбоя в работе, обеспечению отказоустойчивости и иных параметров, позволяющих использовать Ensi. Правообладатель не несет ответственности за любые убытки, упущенную выгоду, связанную с повреждением имущества, неполученным доходом, прерыванием коммерческой или производственной деятельности, возникшие вследствие использования Ensi лицензиатом. + +6. Заключительные положения + +6.1. Оферта вступает в силу с даты ее размещения на Сайте платформы и действует до момента прекращения исключительных прав на Ensi у Правообладателя. + +6.2. Переход исключительного права на Ensi к новому правообладателю не будет являться основанием для изменения или расторжения Лицензионного договора. + +6.3. К отношениям между Правообладателем и лицензиатом применяется право Российской Федерации. + +6.4. Реквизиты Правообладателя: +Общество с ограниченной ответственностью «ГринСайт» +ОГРН 11 087 746 328 812 +ИНН 7 735 538 694 +КПП 773 501 001 \ No newline at end of file diff --git a/README.md b/README.md index efc70eb..cdaa4e6 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,27 @@ # Laravel OpenApi Testing +[![Latest Version on Packagist](https://img.shields.io/packagist/v/ensi/laravel-openapi-testing.svg?style=flat-square)](https://packagist.org/packages/ensi/laravel-openapi-testing) +[![Tests](https://github.com/ensi-platform/laravel-openapi-testing/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/ensi-platform/laravel-openapi-testing/actions/workflows/run-tests.yml) +[![Total Downloads](https://img.shields.io/packagist/dt/ensi/laravel-openapi-testing.svg?style=flat-square)](https://packagist.org/packages/ensi/laravel-openapi-testing) + This packages is based on `ensi/openapi-httpfoundation-testing` and provides `ValidatesAgainstOpenApiSpec` trait ## Installation You can install the package via composer: -`composer require ensi/laravel-openapi-testing` +```bash +composer require ensi/laravel-openapi-testing --dev +``` + +## Version Compatibility + +| Laravel OpenApi Testing | PHP | +|-------------------------|------| +| ^0.1.0 | ^8.0 | +| ^0.2.0 | ^8.0 | +| ^0.3.0 | ^8.0 | +| ^0.4.0 | ^8.1 | ## Basic usage @@ -63,12 +78,11 @@ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. ### Testing 1. composer install -2. npm i -3. composer test +2. composer test ## Security Vulnerabilities -Please review [our security policy](../../security/policy) on how to report security vulnerabilities. +Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities. ## License diff --git a/composer.json b/composer.json index 1806549..e368c5e 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,20 @@ { "name": "ensi/laravel-openapi-testing", - "description": "", - "keywords": [ - "laravel", - "factory" - ], - "license": "MIT", + "description": "laravel openapi testing", "type": "library", - "authors": [ - { - "name": "Ilya Nekrasov", - "email": "nekrasov@greensight.ru" - } - ], + "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.1", "ensi/openapi-httpfoundation-testing": "^0.0.3" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", - "mockery/mockery": "^1.4", - "orchestra/testbench": "^6.0||^7.0||^8.0||^9.0", - "pestphp/pest": "^1.16||^2.0", - "php-parallel-lint/php-var-dump-check": "^0.5.0", - "phpunit/phpunit": "^9.0||^10.0||^11.0" + "pestphp/pest": "^1.22 || ^2.0", + "pestphp/pest-plugin-laravel": "^1.1 || ^2.0", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^1.11", + "spaze/phpstan-disallowed-calls": "^2.15", + "orchestra/testbench": "^7.0 || ^8.0 || ^9.0" }, "autoload": { "psr-4": { @@ -35,15 +26,18 @@ "Ensi\\LaravelOpenApiTesting\\Tests\\": "tests" } }, - "minimum-stability": "dev", "scripts": { "cs": "php-cs-fixer fix --config .php-cs-fixer.php", - "test": "vendor/bin/pest" + "phpstan": "phpstan analyse", + "test": "./vendor/bin/pest --parallel --no-coverage", + "test-ci": "./vendor/bin/pest --no-coverage", + "test-coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --parallel --coverage" }, "config": { "sort-packages": true, "allow-plugins": { - "pestphp/pest-plugin": true + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true } } } diff --git a/phpstan-package.neon b/phpstan-package.neon new file mode 100644 index 0000000..e69de29 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..a2205ac --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,61 @@ +includes: + - ./vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon + - ./phpstan-package.neon + +parameters: + paths: + - src + + scanFiles: + + # Pest handles loading custom helpers only when running tests + # @see https://pestphp.com/docs/helpers#usage + - tests/Pest.php + + # The level 9 is the highest level + level: 5 + + ignoreErrors: + - '#PHPDoc tag @var#' + + - '#Unsafe usage of new static\(\)\.#' + + # Pest implicitly binds $this to the current test case + # @see https://pestphp.com/docs/underlying-test-case + - + message: '#^Undefined variable: \$this$#' + path: '*Test.php' + + # Pest custom expectations are dynamic and not conducive static analysis + # @see https://pestphp.com/docs/expectations#custom-expectations + - + message: '#Call to an undefined method Pest\\Expectation|Pest\\Support\\Extendable::#' + path: '*Test.php' + + # Pest allow pass any array for TestCall::with + - + message: '#Parameter \#\d ...\$data of method Pest\\PendingCalls\\TestCall::with(.*) array(.*)given#' + path: '*Test.php' + + # Ignore custom method for Faker\Generator + - + message: '#Call to an undefined method Faker\\Generator|Ensi\\TestFactories\\FakerProvider::#' + path: '*Factory.php' + + # Ignore transfer of UploadedFile in auto-generated lib + - + message: '#expects SplFileObject\|null, Illuminate\\Http\\UploadedFile given.#' + path: '*Action.php' + + excludePaths: + - ./*/*/FileToBeExcluded.php + + disallowedFunctionCalls: + - + function: 'dd()' + message: 'use some logger instead' + - + function: 'dump()' + message: 'use some logger instead' + + reportUnmatchedIgnoredErrors: false diff --git a/phpunit.xml b/phpunit.xml index 8f4b58c..c2a4f58 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,14 +5,16 @@ colors="true" > - - ./tests + + tests - + - ./app - ./src + ./src + + + diff --git a/src/CachedValidator.php b/src/CachedValidator.php index ee8da39..7b443de 100644 --- a/src/CachedValidator.php +++ b/src/CachedValidator.php @@ -69,7 +69,7 @@ protected static function getMd5DirHash(string $dir): string { $array = []; $dir = realpath($dir); - $fileSPLObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST); + $fileSPLObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST); foreach ($fileSPLObjects as $fullFileName => $fileSPLObject) { if ($fileSPLObject->isFile()) { $array[] = $fullFileName; diff --git a/src/ValidatesAgainstOpenApiSpec.php b/src/ValidatesAgainstOpenApiSpec.php index 740a3fe..48a3bad 100644 --- a/src/ValidatesAgainstOpenApiSpec.php +++ b/src/ValidatesAgainstOpenApiSpec.php @@ -165,8 +165,8 @@ private function handleFailedValidationException(ValidationException $exception, $extraMessage = ''; if ($keyWordMismatchException) { $extraMessage .= PHP_EOL; - $extraMessage .= 'Key: ' . implode(' -> ', $keyWordMismatchException->dataBreadCrumb()->buildChain()). PHP_EOL; - $extraMessage .= 'Error: '. $keyWordMismatchException->getMessage() . PHP_EOL; + $extraMessage .= 'Key: ' . implode(' -> ', $keyWordMismatchException->dataBreadCrumb()->buildChain()) . PHP_EOL; + $extraMessage .= 'Error: ' . $keyWordMismatchException->getMessage() . PHP_EOL; $extraMessage .= 'Content: ' . PHP_EOL; $extraMessage .= json_encode(json_decode($content), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . PHP_EOL; } diff --git a/tests/Pest.php b/tests/Pest.php index 5949c61..0f3e0ac 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,7 @@ in('Feature'); +uses(TestCase::class)->in(__DIR__); + /* |-------------------------------------------------------------------------- @@ -24,9 +27,9 @@ | */ -expect()->extend('toBeOne', function () { - return $this->toBe(1); -}); +//expect()->extend('toBeOne', function () { +// return $this->toBe(1); +//}); /* |-------------------------------------------------------------------------- @@ -39,7 +42,7 @@ | */ -function something() -{ - // .. -} +//function something() +//{ +// // .. +//} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..19e11ca --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,9 @@ + Date: Mon, 27 May 2024 12:44:48 +0300 Subject: [PATCH 2/3] Update run-tests.yml --- .github/workflows/run-tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f22b0e8..8cc5b7e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,10 +15,6 @@ jobs: php: [8.1, 8.2, 8.3] laravel: [9.*, 10.*, 11.*] exclude: - - laravel: 10.* - php: 8.0 - - laravel: 11.* - php: 8.0 - laravel: 11.* php: 8.1 From 72202fc137ad027d29bca5456df409b9c7e9b719 Mon Sep 17 00:00:00 2001 From: Ms_Natali Date: Thu, 30 May 2024 10:37:06 +0300 Subject: [PATCH 3/3] ENSITECH-74 --- .php-cs-fixer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index b9ca63e..a2dce95 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -39,5 +39,6 @@ 'single_trait_insert_per_statement' => true, 'no_whitespace_in_blank_line' => true, 'method_chaining_indentation' => true, + 'single_space_around_construct' => true, ]) ->setFinder($finder);