Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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", "./"]
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# These are supported funding model platforms

github: [Erwane]
liberapay: erwane
buy_me_a_coffee: erwane
thanks_dev: gh/erwane
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,15 +41,15 @@ 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
vendor/bin/phpunit --display-phpunit-deprecations --display-deprecations --display-warnings
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
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "erwane/cakephp-hcaptcha",
"description": "HCaptcha plugin for CakePHP",
"type": "cakephp-plugin",
"version": "2.1.0",
"keywords": [
"cakephp",
"hcaptcha"
Expand All @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
php:
build:
./.docker/
volumes:
- ".:/var/www/html"
10 changes: 0 additions & 10 deletions grumphp.yml

This file was deleted.

15 changes: 7 additions & 8 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?xml version="1.0"?>
<ruleset name="CakePHP hCaptcha">
<ruleset name="Project">
<arg name="colors"/>
<arg name="encoding=UTF-8"/>
<arg name="report=full"/>
<arg name="parallel=8"/>
<arg name="severity=1"/>
<arg name="extensions=php"/>

<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>
<file>./src</file>
<file>./tests</file>

<file>src/</file>
<file>tests/</file>

<rule ref="CakePHP"/>
<arg value="s"/>
<rule ref="CakePHP" />

<rule ref="Generic.Commenting.Todo.CommentFound">
<severity>0</severity>
</rule>
<rule ref="Generic.Commenting.Todo.TaskFound">
<severity>0</severity>
</rule>
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin.php → src/HCaptchaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Cake\Event\EventManager;

/**
* Class Plugin
* Class HCaptchaPlugin
*
* @package HCaptcha
*/
class Plugin extends BasePlugin
class HCaptchaPlugin extends BasePlugin
{
/**
* Initialize plugin.
Expand Down
2 changes: 1 addition & 1 deletion src/View/Widget/HCaptchaWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
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
*/
#[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;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new Plugin();
$this->plugin = new HCaptchaPlugin();
}

public function testInitialize(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Widget/HCaptchaWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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([
Expand Down
Loading