From cae7368e4b60bd67f874600d5bf6604dfa2c8fd5 Mon Sep 17 00:00:00 2001 From: Ryan Olton Date: Wed, 22 Apr 2026 20:33:02 +0000 Subject: [PATCH 1/2] 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. From 4230ac355d0b58949be9b5e1c44018307d1097af Mon Sep 17 00:00:00 2001 From: Erwane Date: Fri, 24 Apr 2026 14:51:07 +0200 Subject: [PATCH 2/2] upgrade to cake 5.3 and fix tests --- .github/workflows/ci.yml | 6 +++--- composer.json | 6 +++--- phpcs.xml | 2 -- src/View/Widget/HCaptchaWidget.php | 2 +- .../{PluginTest.php => HCaptchaPluginTest.php} | 14 +++++++------- tests/TestCase/View/Widget/HCaptchaWidgetTest.php | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) rename tests/TestCase/{PluginTest.php => HCaptchaPluginTest.php} (85%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7f0cc5..ac5a9bd 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.2', '8.4'] 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.2' ]]; 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.2' uses: codecov/codecov-action@v5 with: files: coverage.xml diff --git a/composer.json b/composer.json index c5783ba..45791be 100644 --- a/composer.json +++ b/composer.json @@ -19,14 +19,14 @@ "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" + "phpunit/phpunit": "^11.1.3" }, "autoload": { "psr-4": { diff --git a/phpcs.xml b/phpcs.xml index f542fc9..3345082 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,8 +7,6 @@ - - src/ tests/ 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 85% rename from tests/TestCase/PluginTest.php rename to tests/TestCase/HCaptchaPluginTest.php index 45172ae..500b657 100644 --- a/tests/TestCase/PluginTest.php +++ b/tests/TestCase/HCaptchaPluginTest.php @@ -8,20 +8,20 @@ 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; /** - * Plugin tests + * HCaptchaPlugin 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([