Skip to content

Commit

Permalink
Merge branch 'release/v5'
Browse files Browse the repository at this point in the history
  • Loading branch information
biscolab committed Dec 5, 2020
2 parents a9f5645 + 933da69 commit 586c4f8
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 61 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -13,4 +13,8 @@ vendor/
/coverage.clover
coverage.xml
clover.xml
report/
report/

# testing
.phpunit.result.cache
phpunit.xml.dist.bak
4 changes: 1 addition & 3 deletions .travis.yml
@@ -1,13 +1,11 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

before_script:
- travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction

fast_finish: true
fast_finish: true
19 changes: 10 additions & 9 deletions README.md
@@ -1,6 +1,6 @@
# Laravel ReCAPTCHA v3, checkbox and invisible

Simple and painless Google reCAPTCHA package for Laravel 5.5 or greater
Simple and painless Google reCAPTCHA package for Laravel framework

Available reCAPTCHA versions:

Expand All @@ -14,17 +14,18 @@ Available reCAPTCHA versions:

## System requirements

| Package | reCAPTCHA | PHP | Laravel | Docs |
| ---------------- | ----------------------------- | --------------------- | ---------------------------- | ---------------------------------------------------------------------- |
| 4.2.x or greater | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6, 7, 8 | [latest](https://laravel-recaptcha-docs.biscolab.com) |
| 4.1.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6, 7 | [v4.1.x](https://laravel-recaptcha-docs.biscolab.com/docs/4.1.x/intro) |
| 4.0.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 | [v4.0.x](https://laravel-recaptcha-docs.biscolab.com/docs/4.0.x/intro) |
| 3.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 ready (\*) | [v3.6.1](https://laravel-recaptcha-docs.biscolab.com/docs/3.6.1/intro) |
| 2.x | v2 Invisible, v2 Checkbox | 5.5.9, 7.0 or greater | 5.0 or greater | [v2.0.4](https://laravel-recaptcha-docs.biscolab.com/docs/2.0.4/intro) |
| Package | reCAPTCHA | PHP | Laravel | Docs |
| -------------- | ----------------------------- | --------------------- | ---------------------------- | ---------------------------------------------------------------------- |
| 5.x | v3, v2 Invisible, v2 Checkbox | 7.3 or greater | 7, 8 | [latest](https://laravel-recaptcha-docs.biscolab.com) |
| 4.2.x to 4.4.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6, 7, 8 | [v4.4.x](https://laravel-recaptcha-docs.biscolab.com/docs/4.4.x/intro) |
| 4.1.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6, 7 | [v4.1.x](https://laravel-recaptcha-docs.biscolab.com/docs/4.1.x/intro) |
| 4.0.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 | [v4.0.x](https://laravel-recaptcha-docs.biscolab.com/docs/4.0.x/intro) |
| 3.x | v3, v2 Invisible, v2 Checkbox | 7.1 or greater | 5.5 or greater, 6 ready (\*) | [v3.6.1](https://laravel-recaptcha-docs.biscolab.com/docs/3.6.1/intro) |
| 2.x | v2 Invisible, v2 Checkbox | 5.5.9, 7.0 or greater | 5.0 or greater | [v2.0.4](https://laravel-recaptcha-docs.biscolab.com/docs/2.0.4/intro) |

> (\*) Latest version (3.6.1) is Laravel 6 ready
> If you are migrating from either v2.x or v3.x to the latest package version, please, take a look about migration to v4.x in [What's new in v4.x](https://laravel-recaptcha-docs.biscolab.com/docs/whats-new) before any changes
> If you are migrating to latest version, please take a look at [What's new](https://laravel-recaptcha-docs.biscolab.com/docs/whats-new) before any changes
## Documentation

Expand Down
12 changes: 6 additions & 6 deletions composer.json
@@ -1,7 +1,7 @@
{
"name": "biscolab/laravel-recaptcha",
"description": "Simple and painless Google reCAPTCHA package for Laravel 5.5 or greater",
"version": "4.4.0",
"description": "Simple and painless Google reCAPTCHA package for Laravel framework",
"version": "5.0.0",
"license": "MIT",
"type": "library",
"keywords": [
Expand All @@ -20,12 +20,12 @@
}
],
"require": {
"php": "^7.1",
"laravel/framework": "^5.5|^6.0|^7.0|^8.0"
"php": "^7.3|^8.0",
"laravel/framework": "^7.0|^8.0"
},
"require-dev": {
"orchestra/testbench": "~3.0",
"phpunit/phpunit": "6.*|7.*"
"orchestra/testbench": "5.*|6.*",
"phpunit/phpunit": "^9.1"
},
"autoload": {
"psr-4": {
Expand Down
38 changes: 15 additions & 23 deletions phpunit.xml.dist
@@ -1,25 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./config</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./config</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 3 additions & 3 deletions tests/ReCaptchaCustomApiDomainTest.php
Expand Up @@ -49,9 +49,9 @@ public function testRecaptchaApiDomainChangesByConfig()
*/
public function testRecaptchaApiDomainChangesByConfigInHtmlScriptTagJsApi()
{
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v2->htmlScriptTagJsApi());
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_invisible->htmlScriptTagJsApi());
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v3->htmlScriptTagJsApi());
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v2->htmlScriptTagJsApi());
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_invisible->htmlScriptTagJsApi());
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v3->htmlScriptTagJsApi());
}

/**
Expand Down
11 changes: 5 additions & 6 deletions tests/ReCaptchaHelpersInvisibleTest.php
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2017 - present
* LaravelGoogleRecaptcha - ReCaptchaHelpersInvisibleTest.phpp
Expand Down Expand Up @@ -26,7 +27,6 @@ public function testHtmlScriptTagJsApiCalledByFacade()
->with(["form_id" => "test-form"]);

htmlScriptTagJsApi(["form_id" => "test-form"]);

}

/**
Expand All @@ -40,7 +40,6 @@ public function testHtmlFormButtonCalledByFacade()
->with("Inner text", ['id' => 'button_id']);

htmlFormButton("Inner text", ['id' => 'button_id']);

}

/**
Expand All @@ -53,10 +52,10 @@ public function testGetFormIdCalledByFacade()
->once();

getFormId();

}

public function testHtmlFormButtonConfiguration() {
public function testHtmlFormButtonConfiguration()
{
$button_html = htmlFormButton("Inner text", ['id' => 'button_id', 'class' => 'button_class', 'data-sitekey' => 'custom-data-sitekey', 'data-callback' => 'myCallback']);

$this->assertEquals('<button class="button_class g-recaptcha" data-callback="biscolabLaravelReCaptcha" data-sitekey="api_site_key" id="button_id">Inner text</button>', $button_html);
Expand All @@ -69,11 +68,11 @@ public function testHtmlFormButtonConfiguration() {
public function testHtmlFormSnippetCalledByFacade()
{

$this->expectException('\TypeError');
ReCaptcha::shouldReceive('htmlFormSnippet')
->once();

htmlFormSnippet();

}

public function testGetFormIdReturnDefaultFormIdValue()
Expand All @@ -95,4 +94,4 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('recaptcha.api_site_key', 'api_site_key');
$app['config']->set('recaptcha.version', 'invisible');
}
}
}
2 changes: 1 addition & 1 deletion tests/ReCaptchaHelpersV2Test.php
Expand Up @@ -83,7 +83,7 @@ public function testExpectReCaptchaInstanceOfReCaptchaBuilderV2()
*/
public function testExpectExceptionWhenGetFormIdFunctionIsCalled()
{

$this->expectException('\Error');
getFormId();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ReCaptchaTest.php
Expand Up @@ -94,7 +94,7 @@ public function testReCaptchaV2HtmlFormSnippet()
*/
public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError()
{

$this->expectException('\Error');
$this->recaptcha_invisible->htmlFormSnippet();
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public function testDefaultCurlTimeout()
*/
public function testReCaptchaV2htmlFormButtonShouldThrowError()
{

$this->expectException('\Error');
$this->recaptcha_v2->htmlFormButton();
}

Expand Down
13 changes: 6 additions & 7 deletions tests/ReCaptchaV3Test.php
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2017 - present
* LaravelGoogleRecaptcha - ReCaptchaV3Test.php
Expand Down Expand Up @@ -40,7 +41,7 @@ public function testAction()
{

$r = $this->recaptcha_v3->htmlScriptTagJsApi(['action' => 'someAction']);
$this->assertRegexp('/someAction/', $r);
$this->assertMatchesRegularExpression('/someAction/', $r);
}

/**
Expand All @@ -50,7 +51,7 @@ public function testFetchCallbackFunction()
{

$r = $this->recaptcha_v3->htmlScriptTagJsApi(['callback_then' => 'functionCallbackThen']);
$this->assertRegexp('/functionCallbackThen\(response\)/', $r);
$this->assertMatchesRegularExpression('/functionCallbackThen\(response\)/', $r);
}

/**
Expand All @@ -60,7 +61,7 @@ public function testcCatchCallbackFunction()
{

$r = $this->recaptcha_v3->htmlScriptTagJsApi(['callback_catch' => 'functionCallbackCatch']);
$this->assertRegexp('/functionCallbackCatch\(err\)/', $r);
$this->assertMatchesRegularExpression('/functionCallbackCatch\(err\)/', $r);
}

/**
Expand All @@ -70,7 +71,7 @@ public function testCustomValidationFunction()
{

$r = $this->recaptcha_v3->htmlScriptTagJsApi(['custom_validation' => 'functionCustomValidation']);
$this->assertRegexp('/functionCustomValidation\(token\)/', $r);
$this->assertMatchesRegularExpression('/functionCustomValidation\(token\)/', $r);
}

/**
Expand Down Expand Up @@ -106,7 +107,6 @@ public function testHtmlScriptTagJsApiCalledByFacade()
->with([]);

htmlScriptTagJsApi([]);

}

/**
Expand All @@ -132,6 +132,5 @@ protected function setUp(): void
parent::setUp(); // TODO: Change the autogenerated stub

$this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');

}
}
}

0 comments on commit 586c4f8

Please sign in to comment.