Skip to content

Commit 4cefba6

Browse files
committed
updated tests
1 parent a74629d commit 4cefba6

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ If you want to use v3, please go to: https://github.com/RyanDaDeng/laravel-googl
2020

2121
# DEMO
2222

23+
## Checkbox
24+
25+
<img src="https://github.com/RyanDaDeng/aws-study-notes/blob/master/0DB7E6BA-15ED-45E7-AA12-3CEA05E1483E.png" width="250" height="300" />
26+
2327
## Invisible
2428

2529
<img src="https://github.com/RyanDaDeng/aws-study-notes/blob/master/881545398213_.pic.jpg" width="250" height="300" />

resources/views/googlerecaptchav2/template.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
2+
<style>
3+
@media screen and (max-height: 575px) {
4+
.g-recaptcha {
5+
transform:scale(0.77);-webkit-transform:scale(0.77);transform-origin:0 0;-webkit-transform-origin:0 0;
6+
}
7+
}
8+
</style>
9+
110
<script>
211
function onloadCallback() {
312
@foreach($ids as $id)
13+
document.getElementById('{{$id}}').classList.add("g-recaptcha");
414
let client{{$id}} = grecaptcha.render('{{$id}}', {
515
'sitekey': '{{$publicKey}}',
616
'theme': '{{$theme}}',

src/GoogleReCaptchaV2.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ public function __construct(GoogleReCaptchaV2Service $service)
2929
}
3030

3131
/**
32-
* @param $ids
32+
* @param array $ids
3333
* @return array
3434
*/
35-
public function prepareViewData(...$ids)
35+
public function prepareViewData($ids = [])
3636
{
37+
3738
$data = [
3839
'publicKey' => $this->getConfig()->getSiteKey(),
3940
'ids' => $ids,
@@ -53,8 +54,9 @@ public function prepareViewData(...$ids)
5354
*/
5455
public function render(...$ids)
5556
{
56-
if (! $this->getConfig()->isServiceEnabled()) {
57-
return;
57+
58+
if (!$this->getConfig()->isServiceEnabled()) {
59+
return null;
5860
}
5961
$data = $this->prepareViewData($ids);
6062

tests/ViewTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testView2()
5151
$_service = new GoogleReCaptchaV2Service($configStub, $clientStub);
5252
$service = new GoogleReCaptchaV2($_service);
5353

54-
$data = $service->prepareViewData('contact_us_id');
54+
$data = $service->prepareViewData(['contact_us_id']);
5555

5656
$this->assertEquals('test1', $data['publicKey']);
5757
$this->assertEquals('contact_us_id', $data['ids'][0]);
@@ -82,7 +82,7 @@ public function testView3()
8282
$_service = new GoogleReCaptchaV2Service($configStub, $clientStub);
8383
$service = new GoogleReCaptchaV2($_service);
8484

85-
$data = $service->prepareViewData('contact_us_id', 'contact_us_id2');
85+
$data = $service->prepareViewData(['contact_us_id', 'contact_us_id2']);
8686

8787
$this->assertEquals('test1', $data['publicKey']);
8888
$this->assertEquals('contact_us_id', $data['ids'][0]);

0 commit comments

Comments
 (0)