Skip to content

Commit

Permalink
Merge pull request #39 from ctlabvn/maintanence
Browse files Browse the repository at this point in the history
Maintenance.
  • Loading branch information
ADmad authored Jul 7, 2022
2 parents 2ce5176 + cc42860 commit 60811d7
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 46 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on: [push, pull_request]

jobs:
testsuite:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
prefer-lowest: ['']
php-version: ['7.4', '8.0', '8.1']
include:
- php-version: '7.2'
prefer-lowest: 'prefer-lowest'

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
coverage: pcov

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer install
fi
- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Code Coverage Report
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v2

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: none
tools: vimeo/psalm:4

- name: Composer Install
run: composer install

- name: Run phpcs
run: vendor/bin/phpcs --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/

- name: Run psalm
if: always()
run: psalm --output-format=github
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Build Status](https://travis-ci.org/ctlabvn/Recaptcha.svg?branch=master)](https://travis-ci.org/ctlabvn/Recaptcha) [![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/workflow/status/ctlabvn/Recaptcha/CI/master)](https:/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)
# Integrate Google Recaptcha v2 to your CakePHP project

## Installation
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"cakephp/cakephp": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "~8.5.0",
"cakephp/cakephp-codesniffer": "^4.0"
"phpunit/phpunit": "~8.5.0 || ^9.3",
"cakephp/cakephp-codesniffer": "^4.1"
},
"autoload": {
"psr-4": {
Expand All @@ -46,5 +46,10 @@
"psr-4": {
"Recaptcha\\Test\\": "tests"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
9 changes: 7 additions & 2 deletions src/Controller/Component/RecaptchaComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RecaptchaComponent extends Component
*
* These are merged with user-provided config when the component is used.
*
* @var array
* @var array<string, mixed>
*/
protected $_defaultConfig = [
// This is test only key/secret
Expand All @@ -44,7 +44,12 @@ public function initialize(array $config = []): void
}

$this->setConfig($config);
$this->_registry->getController()->viewBuilder()->setHelpers(['Recaptcha.Recaptcha' => $this->_config]);

$method = 'setHelpers';
if (method_exists($this->getController()->viewBuilder(), 'addHelpers')) {
$method = 'addHelpers';
}
$this->getController()->viewBuilder()->{$method}(['Recaptcha.Recaptcha' => $this->_config]);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
declare(strict_types=1);

use Cake\Core\Configure;

/*
* Test suite bootstrap
*
Expand All @@ -22,3 +24,7 @@
unset($findRoot);
chdir($root);
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';

Configure::write('Error.ignoredDeprecationPaths', [
'src/TestSuite/Fixture/FixtureInjector.php',
]);

0 comments on commit 60811d7

Please sign in to comment.