Skip to content

Commit 49cb397

Browse files
authored
Merge pull request #42 from ctlabvn/maintainance
Misc. maintenance
2 parents df5a539 + 5431e58 commit 49cb397

File tree

5 files changed

+35
-29
lines changed

5 files changed

+35
-29
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
cs-stan:
1414
name: Coding Standard & Static Analysis
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-24.04
1616

1717
steps:
1818
- uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
2323
php-version: '8.1'
2424
extensions: mbstring, intl
2525
coverage: none
26-
tools: vimeo/psalm:5
26+
tools: vimeo/psalm:6
2727

2828
- name: Composer Install
2929
run: composer install

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![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)
2-
[![Latest Stable Version](https://poser.pugx.org/crabstudio/recaptcha/v/stable)](https://packagist.org/packages/crabstudio/recaptcha)
3-
[![Total Downloads](https://poser.pugx.org/crabstudio/recaptcha/downloads)](https://packagist.org/packages/crabstudio/recaptcha)
4-
[![License](https://poser.pugx.org/crabstudio/recaptcha/license)](https://packagist.org/packages/crabstudio/recaptcha)
1+
[![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)
2+
[![Latest Stable Version](https://img.shields.io/packagist/v/crabstudio/recaptcha)](https://packagist.org/packages/crabstudio/recaptcha)
3+
[![Total Downloads](https://img.shields.io/packagist/dt/crabstudio/recaptcha)](https://packagist.org/packages/crabstudio/recaptcha)
4+
[![License](https://img.shields.io/github/license/ctlabvn/Recaptcha)](https://github.com/ctlabvn/Recaptcha/blob/master/LICENSE)
55

66
# Integrate Google Recaptcha v2 to your CakePHP project
77

@@ -11,27 +11,23 @@ You can install this plugin into your CakePHP application using [composer](http:
1111

1212
The recommended way to install composer packages is:
1313

14-
```
14+
```bash
1515
composer require crabstudio/recaptcha
1616
```
1717

18-
followed by the command:
19-
20-
```
21-
composer update
22-
```
23-
2418
## Load plugin
2519

2620
From command line:
27-
```
21+
22+
```bash
2823
bin/cake plugin load Recaptcha
2924
```
3025

3126
## Load Component and Configure
3227

3328
Override default configure from loadComponent:
34-
```
29+
30+
```php
3531
$this->loadComponent('Recaptcha.Recaptcha', [
3632
'enable' => true, // true/false
3733
'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', [
4440
```
4541

4642
Override default configure from app config file:
47-
```
48-
file: config/app.php
43+
44+
```php
45+
// file: config/app.php
4946

5047
/**
5148
* Recaptcha configuration.
@@ -63,10 +60,9 @@ file: config/app.php
6360
```
6461

6562
Override default configure from recaptcha config file:
66-
```
67-
file: config/recaptcha.php
6863

69-
<?php
64+
```php
65+
// ffile: config/recaptcha.php
7066

7167
return [
7268
/**
@@ -86,8 +82,9 @@ return [
8682
```
8783

8884
Load recaptcha config file:
89-
```
90-
file: config/bootstrap.php
85+
86+
```php
87+
// file: config/bootstrap.php
9188

9289
Configure::load('recaptcha', 'default', true);
9390
```
@@ -100,16 +97,19 @@ Config preference:
10097
## Usage
10198

10299
Display recaptcha in your view:
103-
```
100+
101+
```php
104102
<?= $this->Form->create() ?>
105103
<?= $this->Form->control('email') ?>
106-
<?= $this->Recaptcha->display() ?> // Display recaptcha box in your view, if configure has enable = false, nothing will be displayed
104+
// Display recaptcha box in your view, if configure has enable = false, nothing will be displayed
105+
<?= $this->Recaptcha->display() ?>
107106
<?= $this->Form->button() ?>
108107
<?= $this->Form->end() ?>
109108
```
110109

111110
Verify in your controller function
112-
```
111+
112+
```php
113113
public function forgotPassword()
114114
{
115115
if ($this->request->is('post')) {
@@ -121,4 +121,4 @@ Verify in your controller function
121121
}
122122
```
123123

124-
Done
124+
Done.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"cakephp/cakephp": "^5.0"
3535
},
3636
"require-dev": {
37-
"phpunit/phpunit": "^10.1.0",
37+
"phpunit/phpunit": "^10.5.5 || ^11.1.3",
3838
"cakephp/cakephp-codesniffer": "^4.1"
3939
},
4040
"autoload": {

tests/TestCase/Controller/Component/RecaptchaComponentTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
*/
1515
class RecaptchaComponentTest extends TestCase
1616
{
17+
protected Controller $controller;
18+
protected RecaptchaComponent $Recaptcha;
19+
1720
public function setUp(): void
1821
{
1922
parent::setUp();
@@ -43,7 +46,7 @@ public function testVerifyFalse(): void
4346

4447
$this->Recaptcha->expects($this->once())
4548
->method('apiCall')
46-
->will($this->returnValue(''));
49+
->willReturn('');
4750

4851
$this->assertFalse($this->Recaptcha->verify());
4952
}
@@ -54,7 +57,7 @@ public function testVerifyTrue(): void
5457

5558
$this->Recaptcha->expects($this->once())
5659
->method('apiCall')
57-
->will($this->returnValue('{"success":true}'));
60+
->willReturn('{"success":true}');
5861

5962
$this->assertTrue($this->Recaptcha->verify());
6063

tests/TestCase/View/Helper/RecaptchaHelperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
class RecaptchaHelperTest extends TestCase
1414
{
15+
protected View $View;
16+
protected RecaptchaHelper $Recaptcha;
17+
1518
public function setUp(): void
1619
{
1720
parent::setUp();

0 commit comments

Comments
 (0)