From e899ead4555d27e4cf404390e95e900e88a80636 Mon Sep 17 00:00:00 2001 From: Erwane Date: Sat, 4 Jan 2025 13:18:10 +0100 Subject: [PATCH 1/6] tools --- .editorconfig | 15 +++++++----- .gitattributes | 59 ++++++++---------------------------------------- .gitignore | 20 ++++++++-------- README.md | 11 ++++----- grumphp.yml | 4 ++-- phpcs.xml | 15 +++++++----- phpunit.xml | 28 ----------------------- phpunit.xml.dist | 31 +++++++++++++++++++++++++ 8 files changed, 77 insertions(+), 106 deletions(-) delete mode 100644 phpunit.xml create mode 100644 phpunit.xml.dist diff --git a/.editorconfig b/.editorconfig index b0788ad..1e716a7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,18 @@ -# editorconfig.org +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + root = true [*] -indent_style = space +charset = utf-8 indent_size = 4 +indent_style = space end_of_line = lf -trim_trailing_whitespace = true insert_final_newline = true +trim_trailing_whitespace = true + +[*.yml] +indent_size = 2 [*.md] trim_trailing_whitespace = false - -[*.{yaml,yml}] -indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 2a5415d..aa29622 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,49 +1,10 @@ -# Define the line ending behavior of the different file extensions -# Set default behaviour, in case users don't have core.autocrlf set. -* text=auto -* text eol=lf - -# Explicitly declare text files we want to always be normalized and converted -# to native line endings on checkout. -*.php text -*.default text -*.ctp text -*.sql text -*.md text -*.po text -*.js text -*.css text -*.ini text -*.properties text -*.txt text -*.xml text -*.svg text -*.yml text -.htaccess text - -# Declare files that will always have CRLF line endings on checkout. -*.bat eol=crlf - -# Declare files that will always have LF line endings on checkout. -*.pem eol=lf - -# Denote all files that are truly binary and should not be modified. -*.png binary -*.jpg binary -*.gif binary -*.ico binary -*.mo binary -*.pdf binary -*.phar binary -*.woff binary -*.woff2 binary -*.ttf binary -*.otf binary -*.eot binary -*.gz binary -*.bz2 binary -*.7z binary -*.zip binary -*.docx binary -*.xlsx binary -*.mmdb binary +/.github/ export-ignore +/docs/ export-ignore +/tests/ export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.composer.lock export-ignore +/grumphp.yml export-ignore +/phpcs.xml export-ignore +/phpunit.xml.dist export-ignore diff --git a/.gitignore b/.gitignore index b83c577..e9b2bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ -/logs -/tmp -/vendor/ -/.phpunit.cache -/.phpunit.result.cache -/composer.lock +vendor/ +composer.lock +composer.phar + +/phpunit.xml +.phpunit.result.cache +.phpunit.cache + +/coverage.xml # OS generated files # ###################### @@ -29,12 +32,11 @@ Thumbs.db *.tmPreferences.cache # Eclipse .settings/* +/.project +/.buildpath # JetBrains, aka PHPStorm, IntelliJ IDEA .idea/* # NetBeans nbproject/* # Visual Studio Code .vscode -# Sass preprocessor -.sass-cache/ -/.phpstorm.meta.php diff --git a/README.md b/README.md index 43a483c..4cb6d6b 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ # HCaptcha plugin for CakePHP 4.x -![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=1.x) -[![codecov](https://codecov.io/gh/Erwane/cakephp-hcaptcha/branch/1.x/graph/badge.svg?token=NNY4FBXCEE)](https://codecov.io/gh/Erwane/cakephp-hcaptcha) -[![Total Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha?style=flat-square)](https://packagist.org/packages/Erwane/cakephp-hcaptcha/stats) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt) +[![codecov](https://codecov.io/github/Erwane/cakephp-hcaptcha/graph/badge.svg?token=cDRzzPqopA)](https://codecov.io/github/Erwane/cakephp-hcaptcha) +![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=2.x) +[![Packagist Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha) +[![Packagist Version](https://img.shields.io/packagist/v/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha) ## Installation -With composer - -``` +```sh composer require erwane/cakephp-hcaptcha ``` diff --git a/grumphp.yml b/grumphp.yml index 8717109..0dc21a8 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -6,5 +6,5 @@ grumphp: phplint: ~ phpcs: whitelist_patterns: - - /^config\/(.*)/ - - /^src\/(.*)/ + - /^src\/(.*\.php)/ + - /^tests\/(.*\.php)/ diff --git a/phpcs.xml b/phpcs.xml index 233cbb1..f542fc9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,17 +1,20 @@ - + + - - + + + src/ + tests/ + + + - - 0 - 0 diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index ba31130..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - ./tests/TestCase/ - - - - - - src - - - diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..60082c7 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + tests/TestCase + + + + + + src/ + + + From 8a0bc6490bc974f6e5dfd923afea77791d98e658 Mon Sep 17 00:00:00 2001 From: Erwane Date: Sat, 4 Jan 2025 16:06:02 +0100 Subject: [PATCH 2/6] fix phpunit 10.5 tests --- composer.json | 34 ++++--- src/Plugin.php | 2 +- src/Validation.php | 33 +------ src/View/Widget/HCaptchaWidget.php | 12 +-- tests/TestCase/PluginTest.php | 24 +---- tests/TestCase/ValidationTest.php | 91 ++++--------------- .../View/Widget/HCaptchaWidgetTest.php | 38 +++----- tests/bootstrap.php | 22 +---- 8 files changed, 66 insertions(+), 190 deletions(-) diff --git a/composer.json b/composer.json index f6046d0..c5783ba 100644 --- a/composer.json +++ b/composer.json @@ -9,10 +9,25 @@ "license": "MIT", "authors": [ { - "name": "erwane", - "email": "email@example.com" + "name": "Erwane Breton", + "email": "erwane@phea.fr", + "homepage": "https://erwane-breton.fr" } ], + "support": { + "issues": "https://github.com/Erwane/cakephp-hcaptcha/issues", + "source": "https://github.com/Erwane/cakephp-hcaptcha" + }, + "require": { + "php": "^8.1", + "cakephp/cakephp": "^5.0" + }, + "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": { "psr-4": { "HCaptcha\\": "src/" @@ -23,22 +38,13 @@ "HCaptcha\\Test\\": "tests/" } }, - "require": { - "php": "^7.2 | ^8.0", - "ext-intl": "*", - "cakephp/cakephp": "^4.0" - }, - "require-dev": { - "cakephp/cakephp-codesniffer": "^4.0", - "php-parallel-lint/php-parallel-lint": "^1.0", - "phpro/grumphp": "^v0.19 | ^v1.0", - "phpunit/phpunit": "^8.0 | ^9.0" - }, "scripts": { "cscheck": "vendor/bin/phpcs -p src/ tests/", - "csfix": "vendor/bin/phpcbf src/ tests/" + "csfix": "vendor/bin/phpcbf -p src/ tests/" }, "config": { + "platform-check": true, + "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, "phpro/grumphp": true diff --git a/src/Plugin.php b/src/Plugin.php index 94288c5..7a0bb5a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -30,7 +30,7 @@ public function initialize(): void /** * Add HCaptcha widget to FormHelper, if exists. * - * @param \Cake\Event\EventInterface $event Dispatched event + * @param \Cake\Event\EventInterface $event Dispatched event * @return void */ public function addWidget(EventInterface $event): void diff --git a/src/Validation.php b/src/Validation.php index bc29594..c9c0ecc 100644 --- a/src/Validation.php +++ b/src/Validation.php @@ -5,7 +5,6 @@ use Cake\Core\Configure; use Cake\Http\Client; -use Psr\Http\Client\ClientInterface; /** * Class Validation @@ -14,36 +13,6 @@ */ class Validation { - /** - * @var \Psr\Http\Client\ClientInterface - */ - protected static $_client; - - /** - * Set Http client interface - * - * @param \Psr\Http\Client\ClientInterface $client Http client interface - * @return void - */ - public static function setClient(ClientInterface $client): void - { - self::$_client = $client; - } - - /** - * Get Http client - * - * @return \Cake\Http\Client|\Psr\Http\Client\ClientInterface - */ - public static function getClient(): ClientInterface - { - if (!isset(static::$_client)) { - static::$_client = new Client(['timeout' => 3, 'protocolVersion' => '2']); - } - - return static::$_client; - } - /** * Validate captcha * @@ -57,7 +26,7 @@ public static function hcaptcha(string $check): bool 'response' => $check, ]; - $client = self::getClient(); + $client = new Client(['timeout' => 3, 'protocolVersion' => '2']); $response = $client->post('https://hcaptcha.com/siteverify', $data); diff --git a/src/View/Widget/HCaptchaWidget.php b/src/View/Widget/HCaptchaWidget.php index 614c9c5..2ade4c1 100644 --- a/src/View/Widget/HCaptchaWidget.php +++ b/src/View/Widget/HCaptchaWidget.php @@ -22,22 +22,22 @@ class HCaptchaWidget implements WidgetInterface /** * @var \Cake\View\StringTemplate */ - protected $_templates; + protected StringTemplate $_templates; /** * @var \Cake\View\View */ - private $_view; + private View $_view; /** * @var string */ - protected $_apiUrl = 'https://hcaptcha.com/1/api.js'; + protected string $_apiUrl = 'https://hcaptcha.com/1/api.js'; /** - * @var string[] + * @var array */ - protected $_renderAllowedValues = ['explicit', 'onload']; + protected array $_renderAllowedValues = ['explicit', 'onload']; /** * HCaptchaWidget constructor. @@ -117,7 +117,7 @@ public function render(array $data, ContextInterface $context): string * No field should be secured * * @param array $data The data to render. - * @return string[] Array of fields to secure. + * @return array Array of fields to secure. */ public function secureFields(array $data): array { diff --git a/tests/TestCase/PluginTest.php b/tests/TestCase/PluginTest.php index 59ffea2..45172ae 100644 --- a/tests/TestCase/PluginTest.php +++ b/tests/TestCase/PluginTest.php @@ -10,14 +10,14 @@ use Cake\View\View; use HCaptcha\Plugin; use HCaptcha\View\Widget\HCaptchaWidget; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; /** - * Class PluginTest - * - * @package HCaptcha\Test\TestCase - * @uses \HCaptcha\Plugin - * @coversDefaultClass \HCaptcha\Plugin + * Plugin tests */ +#[UsesClass(Plugin::class)] +#[CoversClass(Plugin::class)] class PluginTest extends TestCase { /** @@ -32,22 +32,12 @@ protected function setUp(): void $this->plugin = new Plugin(); } - /** - * @test - * @covers ::initialize - */ public function testInitialize(): void { $listeners = EventManager::instance()->listeners('View.beforeRender'); $this->assertCount(1, $listeners); - $this->assertInstanceOf('\Hcaptcha\Plugin', $listeners[0]['callable'][0]); - $this->assertSame('addWidget', $listeners[0]['callable'][1]); } - /** - * @test - * @covers ::addWidget - */ public function testAddWidgetNoFormHelper(): void { $view = new View(); @@ -59,10 +49,6 @@ public function testAddWidgetNoFormHelper(): void $this->assertNull($result); } - /** - * @test - * @covers ::addWidget - */ public function testAddWidget(): void { $view = new View(); diff --git a/tests/TestCase/ValidationTest.php b/tests/TestCase/ValidationTest.php index e7e314c..7c6de21 100644 --- a/tests/TestCase/ValidationTest.php +++ b/tests/TestCase/ValidationTest.php @@ -3,78 +3,43 @@ namespace HCaptcha\Test\TestCase; -use Cake\Http\Client; +use Cake\Event\EventManager; +use Cake\Http\Client\Request; +use Cake\Http\TestSuite\HttpClientTrait; use Cake\TestSuite\TestCase; use HCaptcha\Validation; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; /** - * Class ValidationTest - * - * @package HCaptcha\Test\TestCase - * @uses \HCaptcha\Validation - * @coversDefaultClass \HCaptcha\Validation + * Validation tests */ +#[UsesClass(Validation::class)] +#[CoversClass(Validation::class)] class ValidationTest extends TestCase { - /** - * @test - * @covers ::getClient - */ - public function testGetClient(): void - { - $client = Validation::getClient(); - $this->assertInstanceOf(Client::class, $client); - $this->assertSame(3, $client->getConfig('timeout')); - } + use HttpClientTrait; - /** - * @test - * @covers ::setClient - * @covers ::hcaptcha - */ public function testHcaptchaResponseFail(): void { - $client = $this->createPartialMock(Client::class, ['post']); - - $response = $this->createPartialMock(Client\Response::class, ['isSuccess']); + $this->mockClientPost('https://hcaptcha.com/siteverify', $this->newClientResponse(403)); - $client->expects($this->once()) - ->method('post') - ->with('https://hcaptcha.com/siteverify', [ + EventManager::instance()->on('HttpClient.beforeSend', function ($event, Request $request) { + parse_str((string)$request->getBody(), $data); + $this->assertEquals([ 'secret' => 'hcaptcha-secret', 'response' => 'testing-post-fail', - ]) - ->willReturn($response); - $response->expects($this->once())->method('isSuccess')->willReturn(false); + ], $data); + }); - Validation::setClient($client); $result = Validation::hcaptcha('testing-post-fail'); $this->assertFalse($result); } - /** - * @test - * @covers ::setClient - * @covers ::hcaptcha - */ public function testHcaptchaSuccessNotSet(): void { - $client = $this->createPartialMock(Client::class, ['post']); - $response = $this->createPartialMock(Client\Response::class, ['isSuccess', 'getJson']); - - $client->expects($this->exactly(2)) - ->method('post') - ->willReturn($response); - - $response->expects($this->exactly(2)) - ->method('isSuccess') - ->willReturn(true); - - $response->expects($this->exactly(2)) - ->method('getJson') - ->willReturnOnConsecutiveCalls(false, ['response']); - - Validation::setClient($client); + $this->mockClientPost('https://hcaptcha.com/siteverify', $this->newClientResponse(200, [], 'false')); + $this->mockClientPost('https://hcaptcha.com/siteverify', $this->newClientResponse(200, [], '"response"')); $result = Validation::hcaptcha('testing-success'); $this->assertFalse($result); @@ -83,29 +48,9 @@ public function testHcaptchaSuccessNotSet(): void $this->assertFalse($result); } - /** - * @test - * @covers ::setClient - * @covers ::hcaptcha - */ public function testHcaptchaSuccess(): void { - $client = $this->createPartialMock(Client::class, ['post']); - $response = $this->createPartialMock(Client\Response::class, ['isSuccess', 'getJson']); - - $client->expects($this->once()) - ->method('post') - ->willReturn($response); - - $response->expects($this->once()) - ->method('isSuccess') - ->willReturn(true); - - $response->expects($this->once()) - ->method('getJson') - ->willReturn(['success' => true]); - - Validation::setClient($client); + $this->mockClientPost('https://hcaptcha.com/siteverify', $this->newClientResponse(200, [], json_encode(['success' => true]))); $result = Validation::hcaptcha('testing-success'); $this->assertTrue($result); diff --git a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php index afc39f2..8525036 100644 --- a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php +++ b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php @@ -6,21 +6,24 @@ use Cake\Core\Configure; use Cake\Log\Engine\ArrayLog; use Cake\Log\Log; +use Cake\TestSuite\PHPUnitConsecutiveTrait; use Cake\TestSuite\TestCase; use Cake\View\Form\ArrayContext; use Cake\View\StringTemplate; use Cake\View\View; use HCaptcha\View\Widget\HCaptchaWidget; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; /** - * Class HCaptchaWidgetTest - * - * @package HCaptcha\Test\TestCase\View\Widget - * @uses \HCaptcha\View\Widget\HCaptchaWidget - * @coversDefaultClass \HCaptcha\View\Widget\HCaptchaWidget + * HCaptchaWidget tests */ +#[UsesClass(HCaptchaWidget::class)] +#[CoversClass(HCaptchaWidget::class)] class HCaptchaWidgetTest extends TestCase { + use PHPUnitConsecutiveTrait; + /** * @var \HCaptcha\View\Widget\HCaptchaWidget */ @@ -52,18 +55,15 @@ protected function setUp(): void $this->widget = new HCaptchaWidget($templates, $view); } - /** - * @test - * @covers ::__construct - * @covers ::render - */ public function testRenderWithoutJs(): void { $context = new ArrayContext([]); $this->form->expects($this->exactly(2)) ->method('unlockField') - ->withConsecutive(['field'], ['g-recaptcha-response']); + ->with( + ...self::withConsecutive(['field'], ['g-recaptcha-response']) + ); $this->html->expects($this->never())->method('script'); @@ -71,10 +71,6 @@ public function testRenderWithoutJs(): void $this->assertSame('
', $result); } - /** - * @test - * @covers ::render - */ public function testRenderNoKey(): void { $context = new ArrayContext([]); @@ -85,10 +81,6 @@ public function testRenderNoKey(): void $this->assertSame(['error: Configure HCaptcha.key in your app_local.php file'], $log->read()); } - /** - * @test - * @covers ::render - */ public function testRenderSimple(): void { Configure::write('HCaptcha.key', 'testing-site-key'); @@ -102,10 +94,6 @@ public function testRenderSimple(): void $this->assertSame('
', $result); } - /** - * @test - * @covers ::render - */ public function testRenderWithOptions(): void { Configure::write('HCaptcha.key', 'testing-site-key'); @@ -128,10 +116,6 @@ public function testRenderWithOptions(): void $this->assertSame('
', $result); } - /** - * @test - * @covers ::secureFields - */ public function testSecureFields(): void { $this->assertSame([], $this->widget->secureFields(['name' => 'testing'])); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8ee14f0..c45a05b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,31 +1,17 @@ Date: Sat, 4 Jan 2025 16:15:36 +0100 Subject: [PATCH 3/6] support phpunit 11.x --- tests/TestCase/View/Widget/HCaptchaWidgetTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php index 8525036..0401ca8 100644 --- a/tests/TestCase/View/Widget/HCaptchaWidgetTest.php +++ b/tests/TestCase/View/Widget/HCaptchaWidgetTest.php @@ -44,13 +44,13 @@ protected function setUp(): void parent::setUp(); $templates = new StringTemplate(); - $view = $this->createMock(View::class); + $view = new View(); $this->form = $this->createPartialMock('Cake\View\Helper\FormHelper', ['unlockField']); $this->html = $this->createPartialMock('Cake\View\Helper\HtmlHelper', ['script']); - $view->Form = $this->form; - $view->Html = $this->html; + $view->loadHelper('Form', ['className' => $this->form]); + $view->loadHelper('Html', ['className' => $this->html]); $this->widget = new HCaptchaWidget($templates, $view); } From fb49389d8a639dc3decdab99e5ff45e18c6f7e44 Mon Sep 17 00:00:00 2001 From: Erwane Date: Sat, 4 Jan 2025 16:21:44 +0100 Subject: [PATCH 4/6] CI workflow --- .github/workflows/ci.yml | 49 ++++++++++++++++++++-------------------- README.md | 7 ++++++ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12c184b..a7f0cc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,14 @@ name: CI on: push: branches: - - 1.x + - '2.x' pull_request: branches: - '*' + workflow_dispatch: + +permissions: + contents: read # to fetch code (actions/checkout) jobs: testsuite: @@ -14,44 +18,39 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '8.0', '8.1'] + php-version: ['8.1', '8.3'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }} - ini-values: apc.enable_cli = 1 + extensions: mbstring, intl + ini-values: zend.assertions = 1 coverage: pcov - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Get date part for cache key - id: key-date - run: echo "::set-output name=date::$(date +'%Y-%m')" - - - name: Cache composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} - - name: Composer install - run: | - composer update + uses: ramsey/composer-install@v3 + with: + dependency-versions: ${{ matrix.dependencies }} + composer-options: "${{ matrix.composer-options }}" - name: Run PHPUnit + env: + XDEBUG_MODE: coverage run: | - if [[ ${{ matrix.php-version }} == '8.1' ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml + if [[ '${{ matrix.php-version }}' == '8.1' ]]; then + export CODECOVERAGE=1 + vendor/bin/phpunit --display-warnings --display-incomplete --coverage-clover=coverage.xml else - vendor/bin/phpunit + vendor/bin/phpunit --display-phpunit-deprecations --display-deprecations --display-warnings fi + - name: Submit code coverage if: matrix.php-version == '8.1' - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 + with: + files: coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 4cb6d6b..e7a01c1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ [![Packagist Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha) [![Packagist Version](https://img.shields.io/packagist/v/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha) +## Version map + +| branch | CakePHP core | PHP min | +|--------|--------------|---------| +| 1.x | ^4.0 | PHP 7.2 | +| 2.x | ^5.0 | PHP 8.1 | + ## Installation ```sh From f6a50184c98c317c1e7635aa8997de19de15971d Mon Sep 17 00:00:00 2001 From: Erwane Date: Sat, 4 Jan 2025 16:23:06 +0100 Subject: [PATCH 5/6] fix potential polymorphic call --- src/Plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 7a0bb5a..6619423 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -44,7 +44,7 @@ public function addWidget(EventInterface $event): void } /** @var \Cake\View\Helper\FormHelper $formHelper */ - $view->helpers()->get('Form') - ->addWidget('hcaptcha', ['HCaptcha.HCaptcha', '_view']); + $formHelper = $view->helpers()->get('Form'); + $formHelper->addWidget('hcaptcha', ['HCaptcha.HCaptcha', '_view']); } } From 0c7b8c0f9b2d660fbeaddbcb9283b1e872f9c46d Mon Sep 17 00:00:00 2001 From: Erwane Date: Sat, 4 Jan 2025 16:25:52 +0100 Subject: [PATCH 6/6] codecov badge for 2.x --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7a01c1..879aecf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # HCaptcha plugin for CakePHP 4.x [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt) -[![codecov](https://codecov.io/github/Erwane/cakephp-hcaptcha/graph/badge.svg?token=cDRzzPqopA)](https://codecov.io/github/Erwane/cakephp-hcaptcha) +[![codecov](https://codecov.io/gh/Erwane/cakephp-hcaptcha/branch/2.x/graph/badge.svg?token=NNY4FBXCEE)](https://codecov.io/gh/Erwane/cakephp-hcaptcha) ![Build Status](https://github.com/Erwane/cakephp-hcaptcha/actions/workflows/ci.yml/badge.svg?branch=2.x) [![Packagist Downloads](https://img.shields.io/packagist/dt/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha) [![Packagist Version](https://img.shields.io/packagist/v/Erwane/cakephp-hcaptcha)](https://packagist.org/packages/Erwane/cakephp-hcaptcha)