From 2ebda39f261918b5d86978c957c2c175a86381d0 Mon Sep 17 00:00:00 2001 From: Erwane Date: Thu, 25 Jun 2026 11:17:21 +0200 Subject: [PATCH 1/4] Docker env --- .docker/Dockerfile | 13 +++++++++++++ .gitattributes | 4 ++-- .github/FUNDING.yml | 6 ++++++ composer.json | 6 +++--- docker-compose.yaml | 6 ++++++ grumphp.yml | 10 ---------- phpcs.xml | 15 +++++++-------- 7 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 .docker/Dockerfile create mode 100644 .github/FUNDING.yml create mode 100644 docker-compose.yaml delete mode 100644 grumphp.yml diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..5926dd2 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.2-cli-alpine AS final + +ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +RUN install-php-extensions ctype curl intl json mbstring xml xdebug + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer +ENV COMPOSER_ALLOW_SUPERUSER=1 + +WORKDIR /var/www/html + +# keep container up +CMD ["php", "-S", "0.0.0.0:80", "-t", "./"] diff --git a/.gitattributes b/.gitattributes index aa29622..43bbe3a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,10 @@ +/.docker/ export-ignore /.github/ export-ignore -/docs/ export-ignore /tests/ export-ignore .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.composer.lock export-ignore +docker-compose.yaml export-ignore /grumphp.yml export-ignore /phpcs.xml export-ignore /phpunit.xml.dist export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..24a2c61 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,6 @@ +# These are supported funding model platforms + +github: [Erwane] +liberapay: erwane +buy_me_a_coffee: erwane +thanks_dev: gh/erwane diff --git a/composer.json b/composer.json index c5783ba..15cafa8 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "erwane/cakephp-hcaptcha", "description": "HCaptcha plugin for CakePHP", "type": "cakephp-plugin", + "version": "2.1.0", "keywords": [ "cakephp", "hcaptcha" @@ -19,13 +20,12 @@ "source": "https://github.com/Erwane/cakephp-hcaptcha" }, "require": { - "php": "^8.1", - "cakephp/cakephp": "^5.0" + "php": "^8.2", + "cakephp/cakephp": "^5.3" }, "require-dev": { "cakephp/cakephp-codesniffer": "^5.0", "php-parallel-lint/php-parallel-lint": "^1.3", - "phpro/grumphp": "^2.0", "phpunit/phpunit": "^10.5.5 || ^11.1.3" }, "autoload": { diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..633cd4e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,6 @@ +services: + php: + build: + ./.docker/ + volumes: + - ".:/var/www/html" diff --git a/grumphp.yml b/grumphp.yml deleted file mode 100644 index 0dc21a8..0000000 --- a/grumphp.yml +++ /dev/null @@ -1,10 +0,0 @@ -grumphp: - ascii: - failed: ~ - succeeded: ~ - tasks: - phplint: ~ - phpcs: - whitelist_patterns: - - /^src\/(.*\.php)/ - - /^tests\/(.*\.php)/ diff --git a/phpcs.xml b/phpcs.xml index f542fc9..cb9c01d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,20 +1,19 @@ - + - - + ./src + ./tests - src/ - tests/ - - - + + + 0 + 0 From f6282b280d2de3a28bc07beb4865696148141af8 Mon Sep 17 00:00:00 2001 From: Erwane Date: Thu, 25 Jun 2026 11:18:00 +0200 Subject: [PATCH 2/4] fix tests for cakephp 5.3 compatibility --- src/View/Widget/HCaptchaWidget.php | 2 +- .../{PluginTest.php => HCaptchaPluginTest.php} | 12 ++++++------ tests/TestCase/View/Widget/HCaptchaWidgetTest.php | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) rename tests/TestCase/{PluginTest.php => HCaptchaPluginTest.php} (86%) diff --git a/src/View/Widget/HCaptchaWidget.php b/src/View/Widget/HCaptchaWidget.php index 2ade4c1..3b01bc2 100644 --- a/src/View/Widget/HCaptchaWidget.php +++ b/src/View/Widget/HCaptchaWidget.php @@ -95,7 +95,7 @@ public function render(array $data, ContextInterface $context): string if ($data['recaptchacompat'] !== null) { $queryArgs['recaptchacompat'] = in_array( $data['recaptchacompat'], - [1, '1', 'y', 'Y', 'yes', 'on'] + [1, '1', 'y', 'Y', 'yes', 'on'], ) ? 'on' : 'off'; } diff --git a/tests/TestCase/PluginTest.php b/tests/TestCase/HCaptchaPluginTest.php similarity index 86% rename from tests/TestCase/PluginTest.php rename to tests/TestCase/HCaptchaPluginTest.php index 45172ae..16284f9 100644 --- a/tests/TestCase/PluginTest.php +++ b/tests/TestCase/HCaptchaPluginTest.php @@ -8,7 +8,7 @@ use Cake\TestSuite\TestCase; use Cake\View\Helper\FormHelper; use Cake\View\View; -use HCaptcha\Plugin; +use HCaptcha\HCaptchaPlugin; use HCaptcha\View\Widget\HCaptchaWidget; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -16,12 +16,12 @@ /** * Plugin tests */ -#[UsesClass(Plugin::class)] -#[CoversClass(Plugin::class)] -class PluginTest extends TestCase +#[UsesClass(HCaptchaPlugin::class)] +#[CoversClass(HCaptchaPlugin::class)] +class HCaptchaPluginTest extends TestCase { /** - * @var \HCaptcha\Plugin + * @var \HCaptcha\HCaptchaPlugin */ private $plugin; @@ -29,7 +29,7 @@ protected function setUp(): void { parent::setUp(); - $this->plugin = new Plugin(); + $this->plugin = new HCaptchaPlugin(); } public function testInitialize(): void diff --git a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php index 0401ca8..7df4413 100644 --- a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php +++ b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php @@ -62,7 +62,7 @@ public function testRenderWithoutJs(): void $this->form->expects($this->exactly(2)) ->method('unlockField') ->with( - ...self::withConsecutive(['field'], ['g-recaptcha-response']) + ...self::withConsecutive(['field'], ['g-recaptcha-response']), ); $this->html->expects($this->never())->method('script'); @@ -103,7 +103,7 @@ public function testRenderWithOptions(): void ->method('script') ->with( 'https://hcaptcha.com/1/api.js?onload=myFunction&render=explicit&hl=fr&recaptchacompat=off', - ['block' => 'script', 'async', 'defer'] + ['block' => 'script', 'async', 'defer'], ); $result = $this->widget->render([ From b45eee46153f7aaa30c66da1b2db12649072c9d4 Mon Sep 17 00:00:00 2001 From: Erwane Date: Thu, 25 Jun 2026 11:20:11 +0200 Subject: [PATCH 3/4] GH workflow use php8.3 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7f0cc5..2cfaf2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.1', '8.3'] + php-version: ['8.3', '8.5'] steps: - uses: actions/checkout@v4 @@ -41,7 +41,7 @@ jobs: env: XDEBUG_MODE: coverage run: | - if [[ '${{ matrix.php-version }}' == '8.1' ]]; then + if [[ '${{ matrix.php-version }}' == '8.3' ]]; then export CODECOVERAGE=1 vendor/bin/phpunit --display-warnings --display-incomplete --coverage-clover=coverage.xml else @@ -49,7 +49,7 @@ jobs: fi - name: Submit code coverage - if: matrix.php-version == '8.1' + if: matrix.php-version == '8.3' uses: codecov/codecov-action@v5 with: files: coverage.xml From c1f50f5d4ee6d622ff1e053c7a7c435ae4690e7c Mon Sep 17 00:00:00 2001 From: Ryan Olton Date: Wed, 22 Apr 2026 20:33:02 +0000 Subject: [PATCH 4/4] CakePHP Plugin naming deprecation https://book.cakephp.org/5.x/appendices/5-3-migration-guide.html#plugin - renamed file Plugin.php to HCaptchaPlugin.php - renamed class Plugin to HCaptchaPlugin --- src/{Plugin.php => HCaptchaPlugin.php} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/{Plugin.php => HCaptchaPlugin.php} (94%) diff --git a/src/Plugin.php b/src/HCaptchaPlugin.php similarity index 94% rename from src/Plugin.php rename to src/HCaptchaPlugin.php index 6619423..39db57a 100644 --- a/src/Plugin.php +++ b/src/HCaptchaPlugin.php @@ -8,11 +8,11 @@ use Cake\Event\EventManager; /** - * Class Plugin + * Class HCaptchaPlugin * * @package HCaptcha */ -class Plugin extends BasePlugin +class HCaptchaPlugin extends BasePlugin { /** * Initialize plugin.