From 323180dbec3a1fffb11cee2d2f198ada0db3e972 Mon Sep 17 00:00:00 2001 From: Contributte AI Date: Sat, 7 Feb 2026 20:46:16 +0000 Subject: [PATCH 1/4] CI: use Contributte reusable workflows, remove obsolete configs --- .github/.kodiak.toml | 10 -- .github/workflows/codesniffer.yml | 18 ++ .github/workflows/coverage.yml | 18 ++ .github/workflows/main.yaml | 267 ------------------------------ .github/workflows/phpstan.yml | 18 ++ .github/workflows/tests.yml | 37 +++++ tests/.coveralls.yml | 4 - 7 files changed, 91 insertions(+), 281 deletions(-) delete mode 100644 .github/.kodiak.toml create mode 100644 .github/workflows/codesniffer.yml create mode 100644 .github/workflows/coverage.yml delete mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/phpstan.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 tests/.coveralls.yml diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml deleted file mode 100644 index 60c34b6..0000000 --- a/.github/.kodiak.toml +++ /dev/null @@ -1,10 +0,0 @@ -version = 1 - -[merge] -automerge_label = "automerge" -blacklist_title_regex = "^WIP.*" -blacklist_labels = ["WIP"] -method = "rebase" -delete_branch_on_merge = true -notify_on_conflict = true -optimistic_updates = false diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml new file mode 100644 index 0000000..a58ac4f --- /dev/null +++ b/.github/workflows/codesniffer.yml @@ -0,0 +1,18 @@ +name: "Codesniffer" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + codesniffer: + name: "Codesniffer" + uses: contributte/.github/.github/workflows/codesniffer.yml@master + with: + php: "8.2" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..fac01f8 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,18 @@ +name: "Coverage" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 9 * * 1" + +jobs: + coverage: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master + with: + php: "8.2" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index b00d276..0000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,267 +0,0 @@ -name: "build" - -on: - pull_request: - paths-ignore: - - ".docs/**" - push: - branches: - - "*" - schedule: - - cron: "0 8 * * 1" # At 08:00 on Monday - -env: - extensions: "json" - cache-version: "1" - composer-version: "v1" - composer-install: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable" - -jobs: - qa: - name: "Quality assurance" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: [ "8.1" ] - operating-system: [ "ubuntu-latest" ] - fail-fast: false - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Validate Composer" - run: "composer validate" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "Coding Standard" - run: "make cs" - - static-analysis: - name: "Static analysis" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: [ "8.1" ] - operating-system: [ "ubuntu-latest" ] - fail-fast: false - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "PHPStan" - run: "make phpstan" - - tests: - name: "Tests" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: ["8.1", "8.2"] - operating-system: [ "ubuntu-latest" ] - composer-args: [ "" ] - include: - - php-version: "8.1" - operating-system: "ubuntu-latest" - composer-args: "--prefer-lowest" - - php-version: "8.3" - operating-system: "ubuntu-latest" - composer-args: "--ignore-platform-reqs" - fail-fast: false - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }} ${{ matrix.composer-args }}" - - - name: "Setup problem matchers for PHPUnit" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"' - - - name: "Tests" - run: "make tests" - - tests-code-coverage: - name: "Tests with code coverage" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: [ "8.1" ] - operating-system: [ "ubuntu-latest" ] - fail-fast: false - - if: "github.event_name == 'push'" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "Tests" - run: "make coverage" - - - name: "Coveralls.io" - env: - CI_NAME: github - CI: true - COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - run: | - wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar - php php-coveralls.phar --verbose --config tests/.coveralls.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..13ceb07 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,18 @@ +name: "Phpstan" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 10 * * 1" + +jobs: + phpstan: + name: "Phpstan" + uses: contributte/.github/.github/workflows/phpstan.yml@master + with: + php: "8.2" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..45e98d5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: "Nette Tester" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 10 * * 1" + +jobs: + test85: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.5" + + test84: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.4" + + test83: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.3" + + testlower: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.2" + composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/tests/.coveralls.yml b/tests/.coveralls.yml deleted file mode 100644 index f94e568..0000000 --- a/tests/.coveralls.yml +++ /dev/null @@ -1,4 +0,0 @@ -# for php-coveralls -service_name: : github-actions -coverage_clover: coverage.xml -json_path: coverage.json From b43e93a0b6ecd3f0a7cc055389ddc0aa4d0fd407 Mon Sep 17 00:00:00 2001 From: Contributte AI Date: Sat, 7 Feb 2026 20:46:25 +0000 Subject: [PATCH 2/4] Config: update deps, phpstan, ruleset, Makefile, editor and git configs --- .editorconfig | 2 +- .gitattributes | 9 + .gitignore | 17 +- Makefile | 52 ++- composer.json | 27 +- phpstan-baseline.neon | 571 +++++++++++++++++++++++++ phpstan.neon | 21 +- phpunit.xml | 13 - ruleset.xml | 45 +- src/Grid/BootstrapCell.php | 2 +- src/Traits/BootstrapContainerTrait.php | 3 +- 11 files changed, 680 insertions(+), 82 deletions(-) create mode 100644 .gitattributes create mode 100644 phpstan-baseline.neon delete mode 100644 phpunit.xml diff --git a/.editorconfig b/.editorconfig index 3faf149..5e5b915 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ indent_style = tab indent_size = tab tab_width = 4 -[{*.json, *.yaml, *.yml, *.md}] +[*.{json,yaml,yml,md}] indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..601a02f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +.docs export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +Makefile export-ignore +README.md export-ignore +phpstan.neon export-ignore +ruleset.xml export-ignore +tests export-ignore diff --git a/.gitignore b/.gitignore index 3171e94..f0b3670 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ -vendor/ -composer.lock -.idea/ \ No newline at end of file +# IDE +/.idea + +# Composer +/vendor +/composer.lock + +# Tests +/tests/tmp +/coverage.* +/tests/**/*.log +/tests/**/*.html +/tests/**/*.expected +/tests/**/*.actual diff --git a/Makefile b/Makefile index 8aa6111..33bc117 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,34 @@ -.PHONY: qa lint cs csf phpstan tests coverage - -all: - @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs - -vendor: composer.json composer.lock - composer install +.PHONY: install +install: + composer update +.PHONY: qa qa: phpstan cs -cs: vendor - vendor/bin/codesniffer src tests - -csf: vendor - vendor/bin/codefixer src tests - -phpstan: vendor - vendor/bin/phpstan analyse -l 7 -c phpstan.neon src - -tests: vendor - vendor/bin/phpunit - -coverage: vendor - vendor/bin/phpunit --coverage-clover=coverage.xml +.PHONY: cs +cs: +ifdef GITHUB_ACTION + vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr +else + vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests +endif + +.PHONY: csf +csf: + vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests + +.PHONY: phpstan +phpstan: + vendor/bin/phpstan analyse -c phpstan.neon + +.PHONY: tests +tests: + vendor/bin/tester -s -p php --colors 1 -C tests/Cases + +.PHONY: coverage +coverage: +ifdef GITHUB_ACTION + vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases +else + vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases +endif diff --git a/composer.json b/composer.json index cbc0703..dad46d7 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,15 @@ } ], "require": { - "php": ">=8.1", - "nette/forms": "3.2.7", - "nette/application": "^3.0" + "php": ">=8.2", + "nette/application": "^3.0.0", + "nette/forms": "^3.2.7" }, "require-dev": { - "contributte/qa": "^v0.3", - "phpunit/phpunit": "^9.5", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-nette": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0" + "contributte/phpstan": "~0.2.0", + "contributte/qa": "~0.4.0", + "contributte/tester": "~0.3.0", + "mockery/mockery": "^1.6.12" }, "autoload": { "psr-4": { @@ -41,14 +39,15 @@ }, "minimum-stability": "dev", "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "0.9.x-dev" - } - }, "config": { + "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } + }, + "extra": { + "branch-alias": { + "dev-master": "0.9.x-dev" + } } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..7a9e347 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,571 @@ +parameters: + ignoreErrors: + - + message: '#^Parameter \#1 \$name \(string\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addContainer\(\) should be contravariant with parameter \$name \(int\|string\) of method Nette\\Forms\\Container\:\:addContainer\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$caption \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addSubmit\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addSubmit\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$caption \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addCheckbox\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addCheckbox\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$content \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addButton\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addButton\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addDateTime\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addDateTime\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addEmail\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addEmail\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addFloat\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addFloat\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addInteger\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addInteger\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addMultiSelect\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addMultiSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addMultiUpload\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addMultiUpload\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addPassword\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addPassword\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addRadioList\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addRadioList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addSelect\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addText\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addText\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addTextArea\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addTextArea\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addUpload\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addUpload\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addCheckboxList\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addCheckboxList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addColor\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addColor\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addDate\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addDate\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addTime\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addTime\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#3 \$items \(array\\|string\>\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addSelect\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addCheckboxList\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addCheckboxList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addMultiSelect\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addMultiSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapContainer\:\:addRadioList\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addRadioList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapContainer.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#1 \$name \(string\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addContainer\(\) should be contravariant with parameter \$name \(int\|string\) of method Nette\\Forms\\Container\:\:addContainer\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$caption \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addSubmit\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addSubmit\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$caption \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addCheckbox\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addCheckbox\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$content \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addButton\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addButton\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addDateTime\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addDateTime\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addEmail\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addEmail\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addFloat\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addFloat\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addInteger\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addInteger\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addMultiSelect\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addMultiSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addMultiUpload\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addMultiUpload\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addPassword\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addPassword\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addRadioList\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addRadioList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addSelect\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addText\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addText\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addTextArea\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addTextArea\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addUpload\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addUpload\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addCheckboxList\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addCheckboxList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addColor\(\) should be contravariant with parameter \$label \(string\|Stringable\|null\) of method Nette\\Forms\\Container\:\:addColor\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addDate\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addDate\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#2 \$label \(string\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addTime\(\) should be contravariant with parameter \$label \(object\|string\|null\) of method Nette\\Forms\\Container\:\:addTime\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#3 \$items \(array\\|string\>\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addSelect\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addCheckboxList\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addCheckboxList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addMultiSelect\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addMultiSelect\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Parameter \#3 \$items \(array\\|null\) of method Contributte\\FormsBootstrap\\BootstrapForm\:\:addRadioList\(\) should be contravariant with parameter \$items \(array\|null\) of method Nette\\Forms\\Container\:\:addRadioList\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapForm.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Class Contributte\\FormsBootstrap\\BootstrapRenderer has PHPDoc tag @property\-read for property \$config with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Class Contributte\\FormsBootstrap\\BootstrapRenderer has PHPDoc tag @property\-read for property \$configOverride with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' + identifier: empty.notAllowed + count: 8 + path: src/BootstrapRenderer.php + + - + message: '#^Instanceof between Nette\\Forms\\Controls\\BaseControl and Nette\\Forms\\Controls\\BaseControl will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in &&, int\<0, max\> given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean + count: 2 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in a negated boolean, Nette\\Utils\\Html\|null given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in a negated boolean, array\ given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in an if condition, Nette\\Utils\\Html\|string given\.$#' + identifier: if.condNotBoolean + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Only booleans are allowed in an if condition, mixed given\.$#' + identifier: if.condNotBoolean + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Parameter \#1 \$form \(Contributte\\FormsBootstrap\\BootstrapForm\) of method Contributte\\FormsBootstrap\\BootstrapRenderer\:\:render\(\) should be contravariant with parameter \$form \(Nette\\Forms\\Form\) of method Nette\\Forms\\FormRenderer\:\:render\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#' + identifier: ternary.shortNotAllowed + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Strict comparison using \!\=\= between Nette\\Utils\\Html and null will always evaluate to true\.$#' + identifier: notIdentical.alwaysTrue + count: 1 + path: src/BootstrapRenderer.php + + - + message: '#^Parameter \#3 \$insertBefore \(null\) of method Contributte\\FormsBootstrap\\Grid\\BootstrapCell\:\:addComponent\(\) should be contravariant with parameter \$insertBefore \(string\|null\) of method Contributte\\FormsBootstrap\\Traits\\BootstrapContainerTrait\:\:addComponent\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Grid/BootstrapCell.php + + - + message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/Grid/BootstrapRow.php + + - + message: '#^Parameter \#1 \$parent \(Nette\\Forms\\Container\|null\) of method Contributte\\FormsBootstrap\\Grid\\BootstrapRow\:\:setParent\(\) should be contravariant with parameter \$parent \(Nette\\ComponentModel\\IContainer\|null\) of method Nette\\ComponentModel\\IComponent\:\:setParent\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Grid/BootstrapRow.php + + - + message: '#^Parameter \#1 \$content \(Nette\\Utils\\Html\|string\|null\) of method Contributte\\FormsBootstrap\\Inputs\\ButtonInput\:\:getControl\(\) should be contravariant with parameter \$caption \(string\|Stringable\|null\) of method Nette\\Forms\\Controls\\Button\:\:getControl\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Inputs/ButtonInput.php + + - + message: '#^Only booleans are allowed in a ternary operator condition, Nette\\Forms\\Rules\|null given\.$#' + identifier: ternary.condNotBoolean + count: 1 + path: src/Inputs/CheckboxInput.php + + - + message: '#^Parameter \#1 \$control of method Contributte\\FormsBootstrap\\Inputs\\CheckboxInput\:\:_rawShowValidation\(\) expects Nette\\Utils\\Html, Nette\\Utils\\Html\|string given\.$#' + identifier: argument.type + count: 1 + path: src/Inputs/CheckboxInput.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/Inputs/CheckboxListInput.php + + - + message: '#^Call to function is_bool\(\) with bool will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Inputs/CheckboxListInput.php + + - + message: '#^Parameter \#1 \$control of method Contributte\\FormsBootstrap\\Inputs\\CheckboxListInput\:\:_rawShowValidation\(\) expects Nette\\Utils\\Html, Nette\\Utils\\Html\|string given\.$#' + identifier: argument.type + count: 1 + path: src/Inputs/CheckboxListInput.php + + - + message: '#^Strict comparison using \=\=\= between \*NEVER\* and mixed will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: src/Inputs/CheckboxListInput.php + + - + message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' + identifier: empty.notAllowed + count: 2 + path: src/Inputs/DateInput.php + + - + message: '#^Only booleans are allowed in a negated boolean, DateTime\|false given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/Inputs/DateInput.php + + - + message: '#^Parameter \#1 \$value \(DateTimeInterface\|null\) of method Contributte\\FormsBootstrap\\Inputs\\DateInput\:\:setValue\(\) should be contravariant with parameter \$value \(mixed\) of method Nette\\Forms\\Control\:\:setValue\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Inputs/DateInput.php + + - + message: '#^Parameter \#1 \$value \(DateTimeInterface\|null\) of method Contributte\\FormsBootstrap\\Inputs\\DateInput\:\:setValue\(\) should be contravariant with parameter \$value \(mixed\) of method Nette\\Forms\\Controls\\TextBase\:\:setValue\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Inputs/DateInput.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/Inputs/MultiselectInput.php + + - + message: '#^Call to function is_bool\(\) with bool will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Inputs/MultiselectInput.php + + - + message: '#^Strict comparison using \=\=\= between \*NEVER\* and mixed will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: src/Inputs/MultiselectInput.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/Inputs/RadioInput.php + + - + message: '#^Call to function is_bool\(\) with bool will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Inputs/RadioInput.php + + - + message: '#^Parameter \#1 \$control of method Contributte\\FormsBootstrap\\Inputs\\RadioInput\:\:_rawShowValidation\(\) expects Nette\\Utils\\Html, Nette\\Utils\\Html\|string given\.$#' + identifier: argument.type + count: 1 + path: src/Inputs/RadioInput.php + + - + message: '#^Strict comparison using \=\=\= between \*NEVER\* and mixed will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: src/Inputs/RadioInput.php + + - + message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#' + identifier: function.strict + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^Call to function is_bool\(\) with bool will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' + identifier: empty.notAllowed + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^PHPDoc tag @var with type array\ is not subtype of native type list\<\(int\|string\)\>\.$#' + identifier: varTag.nativeType + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^Property Nette\\Forms\\Controls\\ChoiceControl\:\:\$items \(array\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^Strict comparison using \=\=\= between \*NEVER\* and mixed will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: src/Inputs/SelectInput.php + + - + message: '#^Parameter \#1 \$caption \(string\|null\) of method Contributte\\FormsBootstrap\\Inputs\\SubmitButtonInput\:\:getControl\(\) should be contravariant with parameter \$caption \(mixed\) of method Nette\\Forms\\Controls\\SubmitButton\:\:getControl\(\)$#' + identifier: method.childParameterType + count: 1 + path: src/Inputs/SubmitButtonInput.php + + - + message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' + identifier: empty.notAllowed + count: 2 + path: src/Inputs/TextInput.php + + - + message: '#^Parameter \#2 \$el of method Contributte\\FormsBootstrap\\BootstrapRenderer\:\:configElem\(\) expects Nette\\Utils\\Html\|null, Nette\\Utils\\Html\|string given\.$#' + identifier: argument.type + count: 1 + path: src/Inputs/UploadInput.php + + - + message: '#^Trait Contributte\\FormsBootstrap\\Traits\\ChoiceInputTrait has PHPDoc tag @method for method getValue\(\) return type with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: src/Traits/ChoiceInputTrait.php + + - + message: '#^Trait Contributte\\FormsBootstrap\\Traits\\ChoiceInputTrait has PHPDoc tag @property for property \$disabled with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: src/Traits/ChoiceInputTrait.php diff --git a/phpstan.neon b/phpstan.neon index c89ee66..242f735 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,17 @@ -parameters: - treatPhpDocTypesAsCertain: false includes: - - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/phpstan/phpstan-nette/extension.neon - - vendor/phpstan/phpstan-nette/rules.neon -# - temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon #we are not ready yet + - vendor/contributte/phpstan/phpstan.neon + - phpstan-baseline.neon + +parameters: + level: 7 + phpVersion: 80200 + treatPhpDocTypesAsCertain: false + + scanDirectories: + - src + + fileExtensions: + - php + paths: + - src diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 79b5f10..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - src - - - - - tests - - - diff --git a/ruleset.xml b/ruleset.xml index b1fd514..2760663 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,25 +1,26 @@ - - - - - - + + + + + + + + + + + + - - - - - - - + + + + + + + + + - - - - - - + + /tests/tmp diff --git a/src/Grid/BootstrapCell.php b/src/Grid/BootstrapCell.php index f89c132..a252c03 100644 --- a/src/Grid/BootstrapCell.php +++ b/src/Grid/BootstrapCell.php @@ -96,7 +96,7 @@ public function render(): Html $element = $renderer->configElem(RendererConfig::GRID_CELL, $element); $element->class[] = $this->createClass(); - foreach ($this->childControls as $childControl) { //@phpstan-ignore-line phpstan bug + foreach ($this->childControls as $childControl) { $pairHtml = $renderer->renderPair($childControl); $element->addHtml($pairHtml); } diff --git a/src/Traits/BootstrapContainerTrait.php b/src/Traits/BootstrapContainerTrait.php index b09543c..9fece17 100644 --- a/src/Traits/BootstrapContainerTrait.php +++ b/src/Traits/BootstrapContainerTrait.php @@ -188,7 +188,8 @@ public function addEmail( string $name, string|\Stringable|null $label = null, int $maxLength = 255 - ): NetteTextInput { + ): NetteTextInput + { return $this->addText($name, $label) ->setNullable(BootstrapForm::$allwaysUseNullable) ->addRule(Form::Email); From 0dc0271fee4087bdb4d751f683c72d0313743df8 Mon Sep 17 00:00:00 2001 From: Contributte AI Date: Sat, 7 Feb 2026 20:46:34 +0000 Subject: [PATCH 3/4] Tests: convert from PHPUnit to Nette Tester --- tests/BaseTest.php | 15 -- tests/BootstrapFormTest.php | 39 ----- tests/BootstrapUtilsTest.php | 18 --- tests/Cases/BootstrapFormTest.phpt | 37 +++++ tests/Cases/BootstrapUtilsTest.phpt | 16 +++ tests/Cases/Grid/BootstrapCellTest.phpt | 61 ++++++++ .../Grid/BootstrapGroupRowRenderingTest.phpt | 45 ++++++ tests/Cases/Inputs/ButtonInputTest.phpt | 22 +++ tests/Cases/Inputs/CheckBoxListTest.phpt | 32 +++++ tests/Cases/Inputs/CheckboxInputTest.phpt | 31 ++++ tests/Cases/Inputs/ColorPickerTest.phpt | 16 +++ tests/Cases/Inputs/DateInputTest.phpt | 24 ++++ tests/Cases/Inputs/DateTimeControlTest.phpt | 15 ++ tests/Cases/Inputs/DateTimeInputTest.phpt | 58 ++++++++ tests/Cases/Inputs/MultiSelectInputTest.phpt | 30 ++++ tests/Cases/Inputs/RadioInputTest.phpt | 26 ++++ tests/Cases/Inputs/SelectInputTest.phpt | 73 ++++++++++ tests/Cases/Inputs/TextAreaInputTest.phpt | 25 ++++ tests/Cases/Inputs/TextInputTest.phpt | 20 +++ tests/Cases/Inputs/UploadInputTest.phpt | 26 ++++ tests/Cases/Rendering/SideBySideTest.phpt | 136 ++++++++++++++++++ tests/Grid/BootstrapCellTest.php | 62 -------- tests/Grid/BootstrapGroupRowRenderingTest.php | 44 ------ tests/Inputs/ButtonInputTest.php | 26 ---- tests/Inputs/CheckBoxListTest.php | 36 ----- tests/Inputs/CheckboxInputTest.php | 35 ----- tests/Inputs/ColorPickerTest.php | 19 --- tests/Inputs/DateInputTest.php | 28 ---- tests/Inputs/DateTimeControlTest.php | 18 --- tests/Inputs/DateTimeInputTest.php | 65 --------- tests/Inputs/MultiSelectInputTest.php | 34 ----- tests/Inputs/RadioInputTest.php | 30 ---- tests/Inputs/SelectInputTest.php | 80 ----------- tests/Inputs/TextAreaInputTest.php | 29 ---- tests/Inputs/TextInputTest.php | 23 --- tests/Inputs/UploadInputTest.php | 30 ---- tests/Rendering/SideBySideTest.php | 98 ------------- tests/bootstrap.php | 4 + 38 files changed, 697 insertions(+), 729 deletions(-) delete mode 100644 tests/BaseTest.php delete mode 100644 tests/BootstrapFormTest.php delete mode 100644 tests/BootstrapUtilsTest.php create mode 100644 tests/Cases/BootstrapFormTest.phpt create mode 100644 tests/Cases/BootstrapUtilsTest.phpt create mode 100644 tests/Cases/Grid/BootstrapCellTest.phpt create mode 100644 tests/Cases/Grid/BootstrapGroupRowRenderingTest.phpt create mode 100644 tests/Cases/Inputs/ButtonInputTest.phpt create mode 100644 tests/Cases/Inputs/CheckBoxListTest.phpt create mode 100644 tests/Cases/Inputs/CheckboxInputTest.phpt create mode 100644 tests/Cases/Inputs/ColorPickerTest.phpt create mode 100644 tests/Cases/Inputs/DateInputTest.phpt create mode 100644 tests/Cases/Inputs/DateTimeControlTest.phpt create mode 100644 tests/Cases/Inputs/DateTimeInputTest.phpt create mode 100644 tests/Cases/Inputs/MultiSelectInputTest.phpt create mode 100644 tests/Cases/Inputs/RadioInputTest.phpt create mode 100644 tests/Cases/Inputs/SelectInputTest.phpt create mode 100644 tests/Cases/Inputs/TextAreaInputTest.phpt create mode 100644 tests/Cases/Inputs/TextInputTest.phpt create mode 100644 tests/Cases/Inputs/UploadInputTest.phpt create mode 100644 tests/Cases/Rendering/SideBySideTest.phpt delete mode 100644 tests/Grid/BootstrapCellTest.php delete mode 100644 tests/Grid/BootstrapGroupRowRenderingTest.php delete mode 100644 tests/Inputs/ButtonInputTest.php delete mode 100644 tests/Inputs/CheckBoxListTest.php delete mode 100644 tests/Inputs/CheckboxInputTest.php delete mode 100644 tests/Inputs/ColorPickerTest.php delete mode 100644 tests/Inputs/DateInputTest.php delete mode 100644 tests/Inputs/DateTimeControlTest.php delete mode 100644 tests/Inputs/DateTimeInputTest.php delete mode 100644 tests/Inputs/MultiSelectInputTest.php delete mode 100644 tests/Inputs/RadioInputTest.php delete mode 100644 tests/Inputs/SelectInputTest.php delete mode 100644 tests/Inputs/TextAreaInputTest.php delete mode 100644 tests/Inputs/TextInputTest.php delete mode 100644 tests/Inputs/UploadInputTest.php delete mode 100644 tests/Rendering/SideBySideTest.php diff --git a/tests/BaseTest.php b/tests/BaseTest.php deleted file mode 100644 index c567fa5..0000000 --- a/tests/BaseTest.php +++ /dev/null @@ -1,15 +0,0 @@ -expectExceptionMessage('Renderer must be a BootstrapRenderer class'); - $form = new BootstrapForm(); - $form->setRenderer(new DefaultFormRenderer()); - } - - public function testGettersAndSetters(): void - { - $form = new BootstrapForm(); - $form->setAutoShowValidation(true); - $this->assertTrue($form->isAutoShowValidation()); - - $form->setAjax(true); - $this->assertTrue($form->isAjax()); - - $form->setRenderMode(RenderMode::SIDE_BY_SIDE_MODE); - $this->assertEquals(RenderMode::SIDE_BY_SIDE_MODE, $form->getRenderMode()); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - $this->assertEquals(BootstrapVersion::V5, BootstrapForm::getBootstrapVersion()); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - $this->assertEquals(BootstrapVersion::V4, BootstrapForm::getBootstrapVersion()); - } - -} diff --git a/tests/BootstrapUtilsTest.php b/tests/BootstrapUtilsTest.php deleted file mode 100644 index e8d0e74..0000000 --- a/tests/BootstrapUtilsTest.php +++ /dev/null @@ -1,18 +0,0 @@ - 'c1 c2']); - BootstrapUtils::standardizeClass($html); - $this->assertEquals(['c1', 'c2'], $html->class); - } - -} diff --git a/tests/Cases/BootstrapFormTest.phpt b/tests/Cases/BootstrapFormTest.phpt new file mode 100644 index 0000000..bdfbdc6 --- /dev/null +++ b/tests/Cases/BootstrapFormTest.phpt @@ -0,0 +1,37 @@ +setRenderer(new DefaultFormRenderer()); + }, \Throwable::class, 'Renderer must be a BootstrapRenderer class'); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $form->setAutoShowValidation(true); + Assert::true($form->isAutoShowValidation()); + + $form->setAjax(true); + Assert::true($form->isAjax()); + + $form->setRenderMode(RenderMode::SIDE_BY_SIDE_MODE); + Assert::equal(RenderMode::SIDE_BY_SIDE_MODE, $form->getRenderMode()); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + Assert::equal(BootstrapVersion::V5, BootstrapForm::getBootstrapVersion()); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); + Assert::equal(BootstrapVersion::V4, BootstrapForm::getBootstrapVersion()); +}); diff --git a/tests/Cases/BootstrapUtilsTest.phpt b/tests/Cases/BootstrapUtilsTest.phpt new file mode 100644 index 0000000..282fccd --- /dev/null +++ b/tests/Cases/BootstrapUtilsTest.phpt @@ -0,0 +1,16 @@ + 'c1 c2']); + BootstrapUtils::standardizeClass($html); + Assert::equal(['c1', 'c2'], $html->class); +}); diff --git a/tests/Cases/Grid/BootstrapCellTest.phpt b/tests/Cases/Grid/BootstrapCellTest.phpt new file mode 100644 index 0000000..7e58f72 --- /dev/null +++ b/tests/Cases/Grid/BootstrapCellTest.phpt @@ -0,0 +1,61 @@ +addRow(); + $cell = $row->addCell(12); + $form->setParent(Mockery::mock(Presenter::class)->shouldIgnoreMissing()); + + $cell->addHtmlClass('new-class'); + Assert::same('
', $cell->render()->render()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $row = $form->addRow(); + $cell = $row->addCell(12); + $form->setParent(Mockery::mock(Presenter::class)->shouldIgnoreMissing()); + + $cell->addSubmit('first', 'First'); + $cell->addSubmit('second', 'Second'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/cell_with_2_submits.html'), $output); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $row = $form->addRow(); + + Assert::exception(function () use ($row): void { + $row->addCell(15); + }, InvalidArgumentException::class); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $row = $form->addRow(); + $cell = $row->addCell(12); + $form->setParent(Mockery::mock(Presenter::class)->shouldIgnoreMissing()); + + $first = $form->addGroup('first'); + $first->add($form->addText('a')); + $form->addGroup('second'); + $cell->setCurrentGroup($first); + + Assert::same($first, $cell->getCurrentGroup()); +}); diff --git a/tests/Cases/Grid/BootstrapGroupRowRenderingTest.phpt b/tests/Cases/Grid/BootstrapGroupRowRenderingTest.phpt new file mode 100644 index 0000000..83d0ab2 --- /dev/null +++ b/tests/Cases/Grid/BootstrapGroupRowRenderingTest.phpt @@ -0,0 +1,45 @@ +addRow('line1'); + $row1->getElementPrototype()->setAttribute('class', 'class1'); + $row1->addCell(6) + ->addSelect('category', 'Category', [1 => 'Category 1', 2 => 'Category 2']) + ->setHtmlAttribute('class', 'selectpicker form-control') + ->setHtmlAttribute('title', 'Choose ...') + ->setRequired(true) + ->getLabelPrototype() + ->setClass('required'); + + $row1->addCell(6) + ->addSelect('type', 'Type', [1 => 'Type 1', 2 => 'Type 2']) + ->setHtmlAttribute('class', 'selectpicker form-control') + ->setHtmlAttribute('title', 'Choose ...') + ->setRequired(true) + ->getLabelPrototype() + ->setClass('required'); + + $form->addGroup('Group 1', false) + ->add([$row1]); + $form->setRenderer(new BootstrapRenderer(RenderMode::SIDE_BY_SIDE_MODE)); + $form->setParent(Mockery::mock(Presenter::class)->shouldIgnoreMissing()); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/bootstrap_group_row_rendering.html'), $output); +}); diff --git a/tests/Cases/Inputs/ButtonInputTest.phpt b/tests/Cases/Inputs/ButtonInputTest.phpt new file mode 100644 index 0000000..c8c2022 --- /dev/null +++ b/tests/Cases/Inputs/ButtonInputTest.phpt @@ -0,0 +1,22 @@ +addButton('btn', 'caption'); + Assert::same('', $btn->getControl()->render()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $btn = $form->addButton('btn', 'caption') + ->setHtmlAttribute('onclick', 'someFunc()'); + Assert::same('', $btn->getControl()->render()); +}); diff --git a/tests/Cases/Inputs/CheckBoxListTest.phpt b/tests/Cases/Inputs/CheckBoxListTest.phpt new file mode 100644 index 0000000..2285222 --- /dev/null +++ b/tests/Cases/Inputs/CheckBoxListTest.phpt @@ -0,0 +1,32 @@ + 2020, 2021 => 2021]; + $control = $form->addCheckboxList('numbers', 'numbers', $items); + $html = $control->getControl()->render(); + $expectedHtml = '
'; + Assert::same($expectedHtml, $html); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $form = new BootstrapForm(); + $items = [2020 => 2020, 2021 => 2021]; + $control = $form->addCheckboxList('numbers', 'numbers', $items); + $html = $control->getControl()->render(); + $expectedHtml = '
'; + Assert::same($expectedHtml, $html); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); diff --git a/tests/Cases/Inputs/CheckboxInputTest.phpt b/tests/Cases/Inputs/CheckboxInputTest.phpt new file mode 100644 index 0000000..c287ed2 --- /dev/null +++ b/tests/Cases/Inputs/CheckboxInputTest.phpt @@ -0,0 +1,31 @@ +addCheckbox('confirm', Html::fromHtml('Confirm')); + $html = $control->getControl()->render(); + $expectedHtml = ''; + Assert::same($expectedHtml, $html); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $form = new BootstrapForm(); + $control = $form->addCheckbox('confirm', Html::fromHtml('Confirm')); + $html = $control->getControl()->render(); + $expectedHtml = ''; + Assert::same($expectedHtml, $html); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); diff --git a/tests/Cases/Inputs/ColorPickerTest.phpt b/tests/Cases/Inputs/ColorPickerTest.phpt new file mode 100644 index 0000000..b1fd49a --- /dev/null +++ b/tests/Cases/Inputs/ColorPickerTest.phpt @@ -0,0 +1,16 @@ +addColor('color', 'Choose color'); + Assert::same('', $input->getControl()->render()); + Assert::same('', (string) $input->getLabel()); +}); diff --git a/tests/Cases/Inputs/DateInputTest.phpt b/tests/Cases/Inputs/DateInputTest.phpt new file mode 100644 index 0000000..c0e528c --- /dev/null +++ b/tests/Cases/Inputs/DateInputTest.phpt @@ -0,0 +1,24 @@ +addBootstrapDate('date', 'Date'); + Assert::same('', $dt->getControl()->render()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + DateInput::$defaultFormat = DateTimeFormat::D_YMD_DASHES; + $dt = $form->addBootstrapDate('date', 'Date'); + Assert::same('', $dt->getControl()->render()); +}); diff --git a/tests/Cases/Inputs/DateTimeControlTest.phpt b/tests/Cases/Inputs/DateTimeControlTest.phpt new file mode 100644 index 0000000..5746f81 --- /dev/null +++ b/tests/Cases/Inputs/DateTimeControlTest.phpt @@ -0,0 +1,15 @@ +addDate('date', 'Date'); + Assert::same('', $dt->getControl()->render()); +}); diff --git a/tests/Cases/Inputs/DateTimeInputTest.phpt b/tests/Cases/Inputs/DateTimeInputTest.phpt new file mode 100644 index 0000000..8956ca5 --- /dev/null +++ b/tests/Cases/Inputs/DateTimeInputTest.phpt @@ -0,0 +1,58 @@ +addBootstrapDateTime('datetime', 'Date and time'); + Assert::same('', $dt->getControl()->render()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + DateTimeInput::$additionalHtmlClasses[] = 'datetimepicker'; + DateTimeInput::$additionalHtmlClasses[] = 'cool'; + $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); + Assert::same('', $dt->getControl()->render()); +}); + +Toolkit::test(function (): void { + DateTimeInput::$additionalHtmlClasses = ['datetime']; + DateInput::$additionalHtmlClasses = ['date']; + + $form = new BootstrapForm(); + $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); + Assert::contains('class="form-control datetime"', $dt->getControl()->render()); + + $d = $form->addBootstrapDate('date', 'Date'); + Assert::contains('class="form-control date"', $d->getControl()->render()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); + $dt->setValue('2020-05-05 20:00:00'); + $submit = $form->addSubmit('send'); + $form->setSubmittedBy($submit); + $form->validate(); + Assert::equal(new DateTime('2020-05-05 20:00:00'), $dt->getValue()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); + $dt->setValue((new DateTime('2020-05-01'))->format($dt->format)); + $submit = $form->addSubmit('send'); + $form->setSubmittedBy($submit); + $form->validate(); + Assert::equal(new DateTime('2020-05-01'), $dt->getValue()); +}); diff --git a/tests/Cases/Inputs/MultiSelectInputTest.phpt b/tests/Cases/Inputs/MultiSelectInputTest.phpt new file mode 100644 index 0000000..25c0f38 --- /dev/null +++ b/tests/Cases/Inputs/MultiSelectInputTest.phpt @@ -0,0 +1,30 @@ +addMultiSelect('test', 'test', ['1' => 'First', '2' => 'Second']); + $html = $select->getControl()->render(); + + Assert::same('', $html); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $form = new BootstrapForm(); + $select = $form->addMultiSelect('test', 'test', ['1' => 'First', '2' => 'Second']); + $html = $select->getControl()->render(); + + Assert::same('', $html); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); diff --git a/tests/Cases/Inputs/RadioInputTest.phpt b/tests/Cases/Inputs/RadioInputTest.phpt new file mode 100644 index 0000000..6834c10 --- /dev/null +++ b/tests/Cases/Inputs/RadioInputTest.phpt @@ -0,0 +1,26 @@ +addRadioList('txt', 'lbl', [1 => '1', 2 => '2']); + Assert::same('
', (string) $input->getControl()); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $form = new BootstrapForm(); + $input = $form->addRadioList('txt', 'lbl', [1 => '1', 2 => '2']); + Assert::same('
', (string) $input->getControl()); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); diff --git a/tests/Cases/Inputs/SelectInputTest.phpt b/tests/Cases/Inputs/SelectInputTest.phpt new file mode 100644 index 0000000..bc2e25c --- /dev/null +++ b/tests/Cases/Inputs/SelectInputTest.phpt @@ -0,0 +1,73 @@ +addSelect('country', 'Country')->setItems($items, false); + Assert::true(array_key_exists('Croatia', $select->getItems())); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $items = ['Croatia', 'Czech', 'Iceland', 'Sweeden']; + $select = $form->addSelect('country', 'Country')->setItems($items, true); + Assert::false(array_key_exists('Croatia', $select->getItems())); +}); + +Toolkit::test(function (): void { + $countries = [ + 'A' => ['B', 'C'], + 'D' => [2 => 'E', 'F'], + ]; + + $form = new BootstrapForm(); + $select = $form->addSelect('test', 'test')->setItems($countries, true); + $html = $select->getControl()->render(); + $expectedHtml = ''; + Assert::same($expectedHtml, $html); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $countries = [ + 'A' => ['B', 'C'], + 'D' => [2 => 'E', 'F'], + ]; + + $form = new BootstrapForm(); + $select = $form->addSelect('test', 'test')->setItems($countries, true); + $html = $select->getControl()->render(); + $expectedHtml = ''; + Assert::same($expectedHtml, $html); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); + +Toolkit::test(function (): void { + Assert::exception(function (): void { + $form = new BootstrapForm(); + $select = $form->addSelect('test', 'test', [null => 'choose']); + $select->setPrompt('Hey'); + }, InvalidArgumentException::class); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $select = $form->addSelect('test', 'test', ['1' => 'First', '2' => 'Second']); + $select->setPrompt(''); + $select->setPrompt('Choose'); + $html = $select->getControl()->render(); + + Assert::contains('Choose', $html); +}); diff --git a/tests/Cases/Inputs/TextAreaInputTest.phpt b/tests/Cases/Inputs/TextAreaInputTest.phpt new file mode 100644 index 0000000..291f7c1 --- /dev/null +++ b/tests/Cases/Inputs/TextAreaInputTest.phpt @@ -0,0 +1,25 @@ +addTextArea('txt', 'lbl', 5, 10); + $input->setAutocomplete(false); + Assert::false($input->getAutocomplete()); + Assert::same('', $input->getControl()->render()); + Assert::same('', (string) $input->getLabel()); +}); + +Toolkit::test(function (): void { + $form = new BootstrapForm(); + $input = $form->addTextArea('txt', Html::el('strong')->setText('test')); + Assert::same('', (string) $input->getLabel()); +}); diff --git a/tests/Cases/Inputs/TextInputTest.phpt b/tests/Cases/Inputs/TextInputTest.phpt new file mode 100644 index 0000000..ad4a449 --- /dev/null +++ b/tests/Cases/Inputs/TextInputTest.phpt @@ -0,0 +1,20 @@ +addText('txt', 'lbl'); + $input->getLabelPrototype()->addHtml('here'); + $input->setAutocomplete(true); + Assert::true($input->getAutocomplete()); + Assert::null($input->getPlaceholder()); + Assert::same('', $input->getControl()->render()); + Assert::same('', (string) $input->getLabel()); +}); diff --git a/tests/Cases/Inputs/UploadInputTest.phpt b/tests/Cases/Inputs/UploadInputTest.phpt new file mode 100644 index 0000000..59b2610 --- /dev/null +++ b/tests/Cases/Inputs/UploadInputTest.phpt @@ -0,0 +1,26 @@ +addUpload('file', 'caption')->setButtonCaption('upload'); + Assert::same('
', $btn->getControl()->render()); +}); + +Toolkit::test(function (): void { + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); + + $form = new BootstrapForm(); + $btn = $form->addUpload('file', 'caption')->setButtonCaption('upload'); + Assert::same('
', $btn->getControl()->render()); + + BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); +}); diff --git a/tests/Cases/Rendering/SideBySideTest.phpt b/tests/Cases/Rendering/SideBySideTest.phpt new file mode 100644 index 0000000..e6d6316 --- /dev/null +++ b/tests/Cases/Rendering/SideBySideTest.phpt @@ -0,0 +1,136 @@ +setRenderer(new BootstrapRenderer(RenderMode::SIDE_BY_SIDE_MODE)); + $form->setParent(Mockery::mock(Presenter::class)->shouldIgnoreMissing()); + + return $form; +} + +Toolkit::test(function (): void { + $form = createForm(); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/empty_form.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->setAction('?a=3&b=aw'); + $form->setMethod('get'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/method_get.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addText('a', 'b'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/text.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $row1 = $form->addRow(); + $cell1 = $row1->addCell(6); + $cell1->addText('name', 'Name'); + $cell2 = $row1->addCell(6); + $cell2->addText('mail', 'Mail'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/simple_grid.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addCheckbox('a', 'b'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/checkbox.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addCheckbox('a', 'b')->setAllignWithInputControls(); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/checkbox_right.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addSubmit('a', 'b'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/submit.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addSubmit('a', 'b')->setAllignWithInputControls(); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/submit_right.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addTextArea('a', 'b'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/textarea.html'), $output); +}); + +Toolkit::test(function (): void { + $form = createForm(); + $form->addText('a')->addError('test-error'); + + ob_start(); + $form->render(); + $output = ob_get_clean(); + + Assert::same(file_get_contents(__DIR__ . '/../../data/side_by_side/text-error.html'), $output); +}); diff --git a/tests/Grid/BootstrapCellTest.php b/tests/Grid/BootstrapCellTest.php deleted file mode 100644 index 29fd611..0000000 --- a/tests/Grid/BootstrapCellTest.php +++ /dev/null @@ -1,62 +0,0 @@ -cell->addHtmlClass('new-class'); - $this->assertEquals('
', $this->cell->render()->render()); - } - - public function testAddMultipleButtons(): void - { - $this->cell->addSubmit('first', 'First'); - $this->cell->addSubmit('second', 'Second'); - $this->form->render(); - $this->expectOutputString($this->loadTextData('cell_with_2_submits.html')); - } - - public function testMoreCellThenAvailable(): void - { - $this->expectException(InvalidArgumentException::class); - $this->row->addCell(15); - } - - public function testGroup(): void - { - $first = $this->form->addGroup('first'); - $first->add($this->form->addText('a')); - $this->form->addGroup('second'); - $this->cell->setCurrentGroup($first); - - $this->assertEquals($first, $this->cell->getCurrentGroup()); - } - - protected function setUp(): void - { - $this->form = new BootstrapForm(); - $this->row = $this->form->addRow(); - $this->cell = $this->row->addCell(12); - $this->form->setParent($this->createMock(Presenter::class)); - } - -} diff --git a/tests/Grid/BootstrapGroupRowRenderingTest.php b/tests/Grid/BootstrapGroupRowRenderingTest.php deleted file mode 100644 index 96fcb61..0000000 --- a/tests/Grid/BootstrapGroupRowRenderingTest.php +++ /dev/null @@ -1,44 +0,0 @@ -addRow('line1'); - $row1->getElementPrototype()->setAttribute('class', 'class1'); - $row1->addCell(6) - ->addSelect('category', 'Category', [1 => 'Category 1', 2 => 'Category 2']) - ->setHtmlAttribute('class', 'selectpicker form-control') - ->setHtmlAttribute('title', 'Choose ...') - ->setRequired(true) - ->getLabelPrototype() - ->setClass('required'); - - $row1->addCell(6) - ->addSelect('type', 'Type', [1 => 'Type 1', 2 => 'Type 2']) - ->setHtmlAttribute('class', 'selectpicker form-control') - ->setHtmlAttribute('title', 'Choose ...') - ->setRequired(true) - ->getLabelPrototype() - ->setClass('required'); - - $form->addGroup('Group 1', false) - ->add([$row1]); - $form->setRenderer(new BootstrapRenderer(RenderMode::SIDE_BY_SIDE_MODE)); - $form->setParent($this->createMock(Presenter::class)); - - $this->expectOutputString($this->loadTextData('bootstrap_group_row_rendering.html')); - $form->render(); - } - -} diff --git a/tests/Inputs/ButtonInputTest.php b/tests/Inputs/ButtonInputTest.php deleted file mode 100644 index 8b6ba5a..0000000 --- a/tests/Inputs/ButtonInputTest.php +++ /dev/null @@ -1,26 +0,0 @@ -addButton('btn', 'caption'); - $this->assertEquals('', $btn->getControl()->render()); - } - - public function testHtmlAttributeButton(): void - { - $form = new BootstrapForm(); - $btn = $form->addButton('btn', 'caption') - ->setHtmlAttribute('onclick', 'someFunc()'); - $this->assertEquals('', $btn->getControl()->render()); - } - -} diff --git a/tests/Inputs/CheckBoxListTest.php b/tests/Inputs/CheckBoxListTest.php deleted file mode 100644 index 1d13f64..0000000 --- a/tests/Inputs/CheckBoxListTest.php +++ /dev/null @@ -1,36 +0,0 @@ - 2020, 2021 => 2021]; - $control = $form->addCheckboxList('numbers', 'numbers', $items); - $html = $control->getControl()->render(); - $expectedHtml = '
'; - $this->assertEquals($expectedHtml, $html); - } - - public function testSetItemsWithKeysAndValueIntegersV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $form = new BootstrapForm(); - $items = [2020 => 2020, 2021 => 2021]; - $control = $form->addCheckboxList('numbers', 'numbers', $items); - $html = $control->getControl()->render(); - $expectedHtml = '
'; - $this->assertEquals($expectedHtml, $html); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - -} diff --git a/tests/Inputs/CheckboxInputTest.php b/tests/Inputs/CheckboxInputTest.php deleted file mode 100644 index e6585d2..0000000 --- a/tests/Inputs/CheckboxInputTest.php +++ /dev/null @@ -1,35 +0,0 @@ -addCheckbox('confirm', Html::fromHtml('Confirm')); - $html = $control->getControl()->render(); - $expectedHtml = ''; - $this->assertEquals($expectedHtml, $html); - } - - public function testHtmlCaptionV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $form = new BootstrapForm(); - $control = $form->addCheckbox('confirm', Html::fromHtml('Confirm')); - $html = $control->getControl()->render(); - $expectedHtml = ''; - $this->assertEquals($expectedHtml, $html); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - -} diff --git a/tests/Inputs/ColorPickerTest.php b/tests/Inputs/ColorPickerTest.php deleted file mode 100644 index 1470ff3..0000000 --- a/tests/Inputs/ColorPickerTest.php +++ /dev/null @@ -1,19 +0,0 @@ -addColor('color', 'Choose color'); - $this->assertEquals('', $input->getControl()->render()); - $this->assertEquals('', (string) $input->getLabel()); - } - -} diff --git a/tests/Inputs/DateInputTest.php b/tests/Inputs/DateInputTest.php deleted file mode 100644 index 8f6ab58..0000000 --- a/tests/Inputs/DateInputTest.php +++ /dev/null @@ -1,28 +0,0 @@ -addBootstrapDate('date', 'Date'); - $this->assertEquals('', $dt->getControl()->render()); - } - - public function testWithCustomStaticFormat(): void - { - $form = new BootstrapForm(); - DateInput::$defaultFormat = DateTimeFormat::D_YMD_DASHES; - $dt = $form->addBootstrapDate('date', 'Date'); - $this->assertEquals('', $dt->getControl()->render()); - } - -} diff --git a/tests/Inputs/DateTimeControlTest.php b/tests/Inputs/DateTimeControlTest.php deleted file mode 100644 index 95c8815..0000000 --- a/tests/Inputs/DateTimeControlTest.php +++ /dev/null @@ -1,18 +0,0 @@ -addDate('date', 'Date'); - $this->assertEquals('', $dt->getControl()->render()); - } - -} diff --git a/tests/Inputs/DateTimeInputTest.php b/tests/Inputs/DateTimeInputTest.php deleted file mode 100644 index 7f86365..0000000 --- a/tests/Inputs/DateTimeInputTest.php +++ /dev/null @@ -1,65 +0,0 @@ -addBootstrapDateTime('datetime', 'Date and time'); - $this->assertEquals('', $dt->getControl()->render()); - } - - public function testDefaultAdditionalClasses(): void - { - $form = new BootstrapForm(); - DateTimeInput::$additionalHtmlClasses[] = 'datetimepicker'; - DateTimeInput::$additionalHtmlClasses[] = 'cool'; - $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); - $this->assertEquals('', $dt->getControl()->render()); - } - - public function testNotMessingHtmlClassOfDateAndDateTime(): void - { - DateTimeInput::$additionalHtmlClasses = ['datetime']; - DateInput::$additionalHtmlClasses = ['date']; - - $form = new BootstrapForm(); - $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); - $this->assertStringContainsString('class="form-control datetime"', $dt->getControl()->render()); - - $d = $form->addBootstrapDate('date', 'Date'); - $this->assertStringContainsString('class="form-control date"', $d->getControl()->render()); - } - - public function testValidationWithValueFromDatabase(): void - { - $form = new BootstrapForm(); - $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); - $dt->setValue('2020-05-05 20:00:00'); - $submit = $form->addSubmit('send'); - $form->setSubmittedBy($submit); - $form->validate(); - $this->assertEquals(new DateTime('2020-05-05 20:00:00'), $dt->getValue()); - } - - public function testValidationWithCorrectFormat(): void - { - $form = new BootstrapForm(); - $dt = $form->addBootstrapDateTime('datetime', 'Date and time'); - $dt->setValue((new DateTime('2020-05-01'))->format($dt->format)); - $submit = $form->addSubmit('send'); - $form->setSubmittedBy($submit); - $form->validate(); - $this->assertEquals(new DateTime('2020-05-01'), $dt->getValue()); - } - -} diff --git a/tests/Inputs/MultiSelectInputTest.php b/tests/Inputs/MultiSelectInputTest.php deleted file mode 100644 index 19de219..0000000 --- a/tests/Inputs/MultiSelectInputTest.php +++ /dev/null @@ -1,34 +0,0 @@ -addMultiSelect('test', 'test', ['1' => 'First', '2' => 'Second']); - $html = $select->getControl()->render(); - - $this->assertEquals('', $html); - } - - public function testMultiSelectV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $form = new BootstrapForm(); - $select = $form->addMultiSelect('test', 'test', ['1' => 'First', '2' => 'Second']); - $html = $select->getControl()->render(); - - $this->assertEquals('', $html); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - -} diff --git a/tests/Inputs/RadioInputTest.php b/tests/Inputs/RadioInputTest.php deleted file mode 100644 index d017b61..0000000 --- a/tests/Inputs/RadioInputTest.php +++ /dev/null @@ -1,30 +0,0 @@ -addRadioList('txt', 'lbl', [1 => '1', 2 => '2']); - $this->assertEquals('
', (string) $input->getControl()); - } - - public function testRadioInputV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $form = new BootstrapForm(); - $input = $form->addRadioList('txt', 'lbl', [1 => '1', 2 => '2']); - $this->assertEquals('
', (string) $input->getControl()); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - -} diff --git a/tests/Inputs/SelectInputTest.php b/tests/Inputs/SelectInputTest.php deleted file mode 100644 index 41aa0a4..0000000 --- a/tests/Inputs/SelectInputTest.php +++ /dev/null @@ -1,80 +0,0 @@ -addSelect('country', 'Country')->setItems($items, false); - $this->assertArrayHasKey('Croatia', $select->getItems()); - } - - public function testSetItemsWithKeysTrue(): void - { - $form = new BootstrapForm(); - $items = ['Croatia', 'Czech', 'Iceland', 'Sweeden']; - $select = $form->addSelect('country', 'Country')->setItems($items, true); - $this->assertArrayNotHasKey('Croatia', $select->getItems()); - } - - public function testItemsAsMultiDimensionalArrayRendering(): void - { - $countries = [ - 'A' => ['B', 'C'], - 'D' => [2 => 'E', 'F'], - ]; - - $form = new BootstrapForm(); - $select = $form->addSelect('test', 'test')->setItems($countries, true); - $html = $select->getControl()->render(); - $expectedHtml = ''; - $this->assertEquals($expectedHtml, $html); - } - - public function testItemsAsMultiDimensionalArrayRenderingV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $countries = [ - 'A' => ['B', 'C'], - 'D' => [2 => 'E', 'F'], - ]; - - $form = new BootstrapForm(); - $select = $form->addSelect('test', 'test')->setItems($countries, true); - $html = $select->getControl()->render(); - $expectedHtml = ''; - $this->assertEquals($expectedHtml, $html); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - - public function testSetPromptWithOneItemAlreadyNullShouldThrowException(): void - { - $this->expectException(InvalidArgumentException::class); - $form = new BootstrapForm(); - $select = $form->addSelect('test', 'test', [null => 'choose']); - $select->setPrompt('Hey'); - } - - public function testSetPrompt(): void - { - $form = new BootstrapForm(); - $select = $form->addSelect('test', 'test', ['1' => 'First', '2' => 'Second']); - $select->setPrompt(''); - $select->setPrompt('Choose'); - $html = $select->getControl()->render(); - - $this->assertStringContainsString('Choose', $html); - } - -} diff --git a/tests/Inputs/TextAreaInputTest.php b/tests/Inputs/TextAreaInputTest.php deleted file mode 100644 index c864665..0000000 --- a/tests/Inputs/TextAreaInputTest.php +++ /dev/null @@ -1,29 +0,0 @@ -addTextArea('txt', 'lbl', 5, 10); - $input->setAutocomplete(false); - $this->assertFalse($input->getAutocomplete()); - $this->assertEquals('', $input->getControl()->render()); - $this->assertEquals('', (string) $input->getLabel()); - } - - public function testTextAreaInputWithLabelHtml(): void - { - $form = new BootstrapForm(); - $input = $form->addTextArea('txt', Html::el('strong')->setText('test')); - $this->assertEquals('', (string) $input->getLabel()); - } - -} diff --git a/tests/Inputs/TextInputTest.php b/tests/Inputs/TextInputTest.php deleted file mode 100644 index bb861d2..0000000 --- a/tests/Inputs/TextInputTest.php +++ /dev/null @@ -1,23 +0,0 @@ -addText('txt', 'lbl'); - $input->getLabelPrototype()->addHtml('here'); - $input->setAutocomplete(true); - $this->assertTrue($input->getAutocomplete()); - $this->assertNull($input->getPlaceholder()); - $this->assertEquals('', $input->getControl()->render()); - $this->assertEquals('', (string) $input->getLabel()); - } - -} diff --git a/tests/Inputs/UploadInputTest.php b/tests/Inputs/UploadInputTest.php deleted file mode 100644 index 1678bc8..0000000 --- a/tests/Inputs/UploadInputTest.php +++ /dev/null @@ -1,30 +0,0 @@ -addUpload('file', 'caption')->setButtonCaption('upload'); - $this->assertEquals('
', $btn->getControl()->render()); - } - - public function testDefaultButtonV5(): void - { - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V5); - - $form = new BootstrapForm(); - $btn = $form->addUpload('file', 'caption')->setButtonCaption('upload'); - $this->assertEquals('
', $btn->getControl()->render()); - - BootstrapForm::switchBootstrapVersion(BootstrapVersion::V4); - } - -} diff --git a/tests/Rendering/SideBySideTest.php b/tests/Rendering/SideBySideTest.php deleted file mode 100644 index e2613dd..0000000 --- a/tests/Rendering/SideBySideTest.php +++ /dev/null @@ -1,98 +0,0 @@ -expectOutputString($this->loadTextData('empty_form.html')); - $this->form->render(); - } - - public function testMethodGet(): void - { - $this->form->setAction('?a=3&b=aw'); - $this->form->setMethod('get'); - $this->expectOutputString($this->loadTextData('method_get.html')); - $this->form->render(); - } - - public function testTextInput(): void - { - $this->form->addText('a', 'b'); - $this->expectOutputString($this->loadTextData('side_by_side/text.html')); - $this->form->render(); - } - - public function testTextRow(): void - { - $row1 = $this->form->addRow(); - $cell1 = $row1->addCell(6); - $cell1->addText('name', 'Name'); - $cell2 = $row1->addCell(6); - $cell2->addText('mail', 'Mail'); - $this->expectOutputString($this->loadTextData('side_by_side/simple_grid.html')); - $this->form->render(); - } - - public function testCheckbox(): void - { - $this->form->addCheckbox('a', 'b'); - $this->expectOutputString($this->loadTextData('side_by_side/checkbox.html')); - $this->form->render(); - } - - public function testCheckboxOnRightSide(): void - { - $this->form->addCheckbox('a', 'b')->setAllignWithInputControls(); - $this->expectOutputString($this->loadTextData('side_by_side/checkbox_right.html')); - $this->form->render(); - } - - public function testSubmit(): void - { - $this->form->addSubmit('a', 'b'); - $this->expectOutputString($this->loadTextData('side_by_side/submit.html')); - $this->form->render(); - } - - public function testSubmitOnRightSide(): void - { - $this->form->addSubmit('a', 'b')->setAllignWithInputControls(); - $this->expectOutputString($this->loadTextData('side_by_side/submit_right.html')); - $this->form->render(); - } - - public function testTextArea(): void - { - $this->form->addTextArea('a', 'b'); - $this->expectOutputString($this->loadTextData('side_by_side/textarea.html')); - $this->form->render(); - } - - public function testErrorRendering(): void - { - $this->form->addText('a')->addError('test-error'); - $this->expectOutputString($this->loadTextData('side_by_side/text-error.html')); - $this->form->render(); - } - - protected function setUp(): void - { - $this->form = new BootstrapForm(); - $this->form->setRenderer(new BootstrapRenderer(RenderMode::SIDE_BY_SIDE_MODE)); - $this->form->setParent($this->createMock(Presenter::class)); - } - -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 558d6ec..b09de76 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,7 @@ Date: Tue, 10 Feb 2026 12:32:11 +0000 Subject: [PATCH 4/4] Tests: fix PHP 8.5 deprecation for null array key --- tests/Cases/Inputs/SelectInputTest.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Cases/Inputs/SelectInputTest.phpt b/tests/Cases/Inputs/SelectInputTest.phpt index bc2e25c..c8f8d01 100644 --- a/tests/Cases/Inputs/SelectInputTest.phpt +++ b/tests/Cases/Inputs/SelectInputTest.phpt @@ -57,7 +57,7 @@ Toolkit::test(function (): void { Toolkit::test(function (): void { Assert::exception(function (): void { $form = new BootstrapForm(); - $select = $form->addSelect('test', 'test', [null => 'choose']); + $select = $form->addSelect('test', 'test', ['' => 'choose']); $select->setPrompt('Hey'); }, InvalidArgumentException::class); });