diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9838894..3a63310 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: cs-stan: name: Coding Standard & Static Analysis - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -23,7 +23,7 @@ jobs: php-version: '8.1' extensions: mbstring, intl coverage: none - tools: vimeo/psalm:5 + tools: vimeo/psalm:6 - name: Composer Install run: composer install diff --git a/README.md b/README.md index 1c53078..9041c39 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Build Status](https://img.shields.io/github/actions/workflow/status/ctlabvn/Recaptcha/ci.yml)](https://github.com/ctlabvn/Recaptcha/actions?query=workflow%3ACI+branch%3Amaster) -[![Latest Stable Version](https://poser.pugx.org/crabstudio/recaptcha/v/stable)](https://packagist.org/packages/crabstudio/recaptcha) -[![Total Downloads](https://poser.pugx.org/crabstudio/recaptcha/downloads)](https://packagist.org/packages/crabstudio/recaptcha) -[![License](https://poser.pugx.org/crabstudio/recaptcha/license)](https://packagist.org/packages/crabstudio/recaptcha) +[![Build Status](https://img.shields.io/github/actions/workflow/status/ctlabvn/Recaptcha/ci.yml?branch=master)](https://github.com/ctlabvn/Recaptcha/actions?query=workflow%3ACI+branch%3Amaster) +[![Latest Stable Version](https://img.shields.io/packagist/v/crabstudio/recaptcha)](https://packagist.org/packages/crabstudio/recaptcha) +[![Total Downloads](https://img.shields.io/packagist/dt/crabstudio/recaptcha)](https://packagist.org/packages/crabstudio/recaptcha) +[![License](https://img.shields.io/github/license/ctlabvn/Recaptcha)](https://github.com/ctlabvn/Recaptcha/blob/master/LICENSE) # Integrate Google Recaptcha v2 to your CakePHP project @@ -11,27 +11,23 @@ You can install this plugin into your CakePHP application using [composer](http: The recommended way to install composer packages is: -``` +```bash composer require crabstudio/recaptcha ``` -followed by the command: - -``` -composer update -``` - ## Load plugin From command line: -``` + +```bash bin/cake plugin load Recaptcha ``` ## Load Component and Configure Override default configure from loadComponent: -``` + +```php $this->loadComponent('Recaptcha.Recaptcha', [ 'enable' => true, // true/false 'sitekey' => 'your_site_key', //if you don't have, get one: https://www.google.com/recaptcha/intro/index.html @@ -44,8 +40,9 @@ $this->loadComponent('Recaptcha.Recaptcha', [ ``` Override default configure from app config file: -``` -file: config/app.php + +```php +// file: config/app.php /** * Recaptcha configuration. @@ -63,10 +60,9 @@ file: config/app.php ``` Override default configure from recaptcha config file: -``` -file: config/recaptcha.php -Form->create() ?> Form->control('email') ?> - Recaptcha->display() ?> // Display recaptcha box in your view, if configure has enable = false, nothing will be displayed + // Display recaptcha box in your view, if configure has enable = false, nothing will be displayed + Recaptcha->display() ?> Form->button() ?> Form->end() ?> ``` Verify in your controller function -``` + +```php public function forgotPassword() { if ($this->request->is('post')) { @@ -121,4 +121,4 @@ Verify in your controller function } ``` -Done +Done. diff --git a/composer.json b/composer.json index 33eaad3..9cbc72f 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "cakephp/cakephp": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.1.0", + "phpunit/phpunit": "^10.5.5 || ^11.1.3", "cakephp/cakephp-codesniffer": "^4.1" }, "autoload": { diff --git a/tests/TestCase/Controller/Component/RecaptchaComponentTest.php b/tests/TestCase/Controller/Component/RecaptchaComponentTest.php index 3127595..5e82573 100644 --- a/tests/TestCase/Controller/Component/RecaptchaComponentTest.php +++ b/tests/TestCase/Controller/Component/RecaptchaComponentTest.php @@ -14,6 +14,9 @@ */ class RecaptchaComponentTest extends TestCase { + protected Controller $controller; + protected RecaptchaComponent $Recaptcha; + public function setUp(): void { parent::setUp(); @@ -43,7 +46,7 @@ public function testVerifyFalse(): void $this->Recaptcha->expects($this->once()) ->method('apiCall') - ->will($this->returnValue('')); + ->willReturn(''); $this->assertFalse($this->Recaptcha->verify()); } @@ -54,7 +57,7 @@ public function testVerifyTrue(): void $this->Recaptcha->expects($this->once()) ->method('apiCall') - ->will($this->returnValue('{"success":true}')); + ->willReturn('{"success":true}'); $this->assertTrue($this->Recaptcha->verify()); diff --git a/tests/TestCase/View/Helper/RecaptchaHelperTest.php b/tests/TestCase/View/Helper/RecaptchaHelperTest.php index f724de8..de4f1fc 100644 --- a/tests/TestCase/View/Helper/RecaptchaHelperTest.php +++ b/tests/TestCase/View/Helper/RecaptchaHelperTest.php @@ -12,6 +12,9 @@ */ class RecaptchaHelperTest extends TestCase { + protected View $View; + protected RecaptchaHelper $Recaptcha; + public function setUp(): void { parent::setUp();