Skip to content

Commit

Permalink
Merge pull request #87 from ARCANEDEV/update-laravel_5.8
Browse files Browse the repository at this point in the history
Adding laravel 5.8 support
  • Loading branch information
arcanedev-maroc committed Feb 27, 2019
2 parents da6bdae + 418b646 commit f012c78
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 119 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ reCAPTCHA comes in the form of a widget that you can easily add to your blog, fo
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `4.2` and `5.0` to `5.7` are supported.
* Laravel `4.2` and `5.0` to `5.8` are supported.
* PSR-7 Support (ServerRequest verification).
* Made with :heart: & :coffee:.

Expand Down
2 changes: 1 addition & 1 deletion _docs/0-Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ reCAPTCHA comes in the form of a widget that you can easily add to your blog, fo
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `4.2` and `5.0` to `5.7` are supported.
* Laravel `4.2` and `5.0` to `5.8` are supported.
* PSR-7 Support (ServerRequest verification).
* Made with :heart: & :coffee:.

Expand Down
3 changes: 3 additions & 0 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For more details, check the [official documentation](https://developers.google.c
| ![noCaptcha v5.x][no_captcha_5_x] | ![Laravel v5.5][laravel_5_5] |
| ![noCaptcha v6.x][no_captcha_6_x] | ![Laravel v5.6][laravel_5_6] |
| ![noCaptcha v7.x][no_captcha_7_x] ![noCaptcha v8.x][no_captcha_8_x] | ![Laravel v5.7][laravel_5_7] |
| ![noCaptcha v9.x][no_captcha_9_x] | ![Laravel v5.8][laravel_5_8] |

> **Note :** This is a framework-agnostic package, so you can use any version of this package in your PHP project.
Expand All @@ -42,6 +43,7 @@ For more details, check the [official documentation](https://developers.google.c
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"

[no_captcha_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "noCaptcha v1.*"
[no_captcha_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "noCaptcha v3.*"
Expand All @@ -50,6 +52,7 @@ For more details, check the [official documentation](https://developers.google.c
[no_captcha_6_x]: https://img.shields.io/badge/version-6.*-blue.svg?style=flat-square "noCaptcha v6.*"
[no_captcha_7_x]: https://img.shields.io/badge/version-7.*-blue.svg?style=flat-square "noCaptcha v7.*"
[no_captcha_8_x]: https://img.shields.io/badge/version-8.*-blue.svg?style=flat-square "noCaptcha v8.*"
[no_captcha_9_x]: https://img.shields.io/badge/version-9.*-blue.svg?style=flat-square "noCaptcha v9.*"

## Composer

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"php": ">=7.1.3",
"ext-curl": "*",
"ext-json": "*",
"arcanedev/php-html": "~1.0.0",
"arcanedev/support": "~4.4.0",
"arcanedev/php-html": "~2.0.0",
"arcanedev/support": "~4.5.0",
"psr/http-message": "~1.0"
},
"require-dev": {
"arcanedev/laravel-html": "~5.7.0",
"orchestra/testbench": "~3.7.0",
"phpunit/phpunit": "~7.0",
"phpunit/phpcov": "~5.0"
"arcanedev/laravel-html": "~5.8.0",
"orchestra/testbench": "~3.8.0",
"phpunit/phpunit": "~7.0|~8.0",
"phpunit/phpcov": "~5.0|~6.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 6 additions & 8 deletions tests/Laravel/NoCaptchaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class NoCaptchaManagerTest extends LaravelTestCase
| -----------------------------------------------------------------
*/

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

$this->manager = $this->app->make(\Arcanedev\NoCaptcha\Contracts\NoCaptchaManager::class);
}

protected function tearDown()
protected function tearDown(): void
{
unset($this->manager);

Expand Down Expand Up @@ -90,14 +90,12 @@ public function it_can_get_driver_by_given_version()
);
}

/**
* @test
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Driver [v1] not supported.
*/
/** @test */
public function it_must_throw_exception_on_unsupported_version()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Driver [v1] not supported.');

$this->manager->version('v1');
}
}
4 changes: 2 additions & 2 deletions tests/Laravel/ValidatorRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class ValidatorRuleTest extends LaravelTestCase
| -----------------------------------------------------------------
*/

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

$this->validator = $this->app['validator'];
}

public function tearDown()
public function tearDown(): void
{
unset($this->validator);

Expand Down
5 changes: 2 additions & 3 deletions tests/LaravelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ protected function getPackageProviders($app)
protected function getPackageAliases($app)
{
return [
'Form' => \Arcanedev\LaravelHtml\Facades\Form::class,
'HTML' => \Arcanedev\LaravelHtml\Facades\Html::class,
'NoCaptcha' => \Arcanedev\NoCaptcha\Facades\NoCaptcha::class,
'Form' => \Arcanedev\LaravelHtml\Facades\Form::class,
'HTML' => \Arcanedev\LaravelHtml\Facades\Html::class,
];
}
}
4 changes: 2 additions & 2 deletions tests/NoCaptchaServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class NoCaptchaServiceProviderTest extends LaravelTestCase
| -----------------------------------------------------------------
*/

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

$this->provider = $this->app->getProvider(NoCaptchaServiceProvider::class);
}

public function tearDown()
public function tearDown(): void
{
unset($this->provider);

Expand Down
86 changes: 36 additions & 50 deletions tests/NoCaptchaV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class NoCaptchaV2Test extends TestCase
| -----------------------------------------------------------------
*/

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

$this->noCaptcha = $this->createCaptcha();
}

public function tearDown()
public function tearDown(): void
{
unset($this->noCaptcha);

Expand Down Expand Up @@ -105,15 +105,16 @@ public function it_can_be_instantiated()
/** @test */
public function it_can_be_instantiated_with_nullable_attributes()
{
$this->noCaptcha = $this->createCaptcha(null, [
$this->noCaptcha = $this->createCaptcha(null);
$attributes = [
'data-theme' => null,
'data-type' => null,
'data-size' => null
]);
];

static::assertSame(
'<div id="captcha" name="captcha" class="g-recaptcha" data-sitekey="site-key"></div>',
$this->noCaptcha->display('captcha')->toHtml()
$this->noCaptcha->display('captcha', $attributes)->toHtml()
);
}

Expand Down Expand Up @@ -177,47 +178,39 @@ public function provideNoCaptchaAttributes()
];
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The secret key must be a string value, NULL given
*/
/** @test */
public function it_must_throw_invalid_type_exception_on_secret_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The secret key must be a string value, NULL given');

new NoCaptchaV2(null, null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The secret key must not be empty
*/
/** @test */
public function it_must_throw_api_exception_on_empty_secret_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The secret key must not be empty');

new NoCaptchaV2(' ', null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The site key must be a string value, NULL given
*/
/** @test */
public function it_must_throw_invalid_type_exception_on_site_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The site key must be a string value, NULL given');

new NoCaptchaV2('secret', null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The site key must not be empty
*/
/** @test */
public function it_must_throw_api_exception_on_empty_site_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The site key must not be empty');

new NoCaptchaV2('secret', ' ');
}

Expand Down Expand Up @@ -542,36 +535,30 @@ public function it_can_render_captcha_with_optional_name()
);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException
* @expectedExceptionMessage The captcha name must be different from "g-recaptcha-response".
*/
/** @test */
public function it_must_throw_an_invalid_argument_exception_when_the_generic_captcha_name_is_same_as_captcha_response_name()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException::class);
$this->expectExceptionMessage('The captcha name must be different from "g-recaptcha-response".');

$this->noCaptcha->display(NoCaptchaV2::CAPTCHA_NAME);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException
* @expectedExceptionMessage The captcha name must be different from "g-recaptcha-response".
*/
/** @test */
public function it_must_throw_an_invalid_argument_exception_when_the_image_captcha_name_is_same_as_captcha_response_name()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException::class);
$this->expectExceptionMessage('The captcha name must be different from "g-recaptcha-response".');

$this->noCaptcha->image(NoCaptchaV2::CAPTCHA_NAME);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException
* @expectedExceptionMessage The captcha name must be different from "g-recaptcha-response".
*/
/** @test */
public function it_must_throw_an_invalid_argument_exception_when_the_audio_captcha_name_is_same_as_captcha_response_name()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException::class);
$this->expectExceptionMessage('The captcha name must be different from "g-recaptcha-response".');

$this->noCaptcha->audio(NoCaptchaV2::CAPTCHA_NAME);
}

Expand All @@ -584,12 +571,11 @@ public function it_must_throw_an_invalid_argument_exception_when_the_audio_captc
* Create Captcha for testing
*
* @param string|null $lang
* @param array $attributes
*
* @return \Arcanedev\NoCaptcha\NoCaptchaV2
*/
private function createCaptcha($lang = null, array $attributes = [])
private function createCaptcha($lang = null)
{
return new NoCaptchaV2('secret-key', 'site-key', $lang, $attributes);
return new NoCaptchaV2('secret-key', 'site-key', $lang);
}
}
44 changes: 18 additions & 26 deletions tests/NoCaptchaV3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class NoCaptchaV3Test extends TestCase
| -----------------------------------------------------------------
*/

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

$this->noCaptcha = $this->createCaptcha();
}

public function tearDown()
public function tearDown(): void
{
unset($this->noCaptcha);

Expand Down Expand Up @@ -110,47 +110,39 @@ public function it_can_be_instantiated_with_defaults()
);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The secret key must be a string value, NULL given
*/
/** @test */
public function it_must_throw_invalid_type_exception_on_secret_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The secret key must be a string value, NULL given');

$this->createCaptcha(null, null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The secret key must not be empty
*/
/** @test */
public function it_must_throw_api_exception_on_empty_secret_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The secret key must not be empty');

$this->createCaptcha(' ', null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The site key must be a string value, NULL given
*/
/** @test */
public function it_must_throw_invalid_type_exception_on_site_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The site key must be a string value, NULL given');

$this->createCaptcha('secret', null);
}

/**
* @test
*
* @expectedException \Arcanedev\NoCaptcha\Exceptions\ApiException
* @expectedExceptionMessage The site key must not be empty
*/
/** @test */
public function it_must_throw_api_exception_on_empty_site_key()
{
$this->expectException(\Arcanedev\NoCaptcha\Exceptions\ApiException::class);
$this->expectExceptionMessage('The site key must not be empty');

$this->createCaptcha('secret', ' ');
}

Expand Down
Loading

0 comments on commit f012c78

Please sign in to comment.