Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
no-captcha
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CENTER-TBI
no-captcha
Commits
ab06d84c
Commit
ab06d84c
authored
Nov 22, 2018
by
Marivaldo Junior
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test displaySubmit with custom data-callback; fix expected/actual order in asserts
parent
0f1d5bb7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
tests/NoCaptchaTest.php
tests/NoCaptchaTest.php
+19
-7
No files found.
tests/NoCaptchaTest.php
View file @
ab06d84c
<?php
<?php
namespace
Anhskohbo\NoCaptcha\Tests
;
use
Anhskohbo\NoCaptcha\NoCaptcha
;
use
Anhskohbo\NoCaptcha\NoCaptcha
;
class
NoCaptchaTest
extends
PHPUnit_Framework_TestCase
class
NoCaptchaTest
extends
PHPUnit_Framework_TestCase
...
@@ -23,9 +25,9 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
...
@@ -23,9 +25,9 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
$withLang
=
'<script src="https://www.google.com/recaptcha/api.js?hl=vi" async defer></script>'
.
"
\n
"
;
$withLang
=
'<script src="https://www.google.com/recaptcha/api.js?hl=vi" async defer></script>'
.
"
\n
"
;
$withCallback
=
'<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=myOnloadCallback" async defer></script>'
.
"
\n
"
;
$withCallback
=
'<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=myOnloadCallback" async defer></script>'
.
"
\n
"
;
$this
->
assertEquals
(
$
this
->
captcha
->
renderJs
(),
$simple
);
$this
->
assertEquals
(
$
simple
,
$this
->
captcha
->
renderJs
()
);
$this
->
assertEquals
(
$
this
->
captcha
->
renderJs
(
'vi'
),
$withLang
);
$this
->
assertEquals
(
$
withLang
,
$this
->
captcha
->
renderJs
(
'vi'
)
);
$this
->
assertEquals
(
$
this
->
captcha
->
renderJs
(
null
,
true
,
'myOnloadCallback'
),
$withCallback
);
$this
->
assertEquals
(
$
withCallback
,
$this
->
captcha
->
renderJs
(
null
,
true
,
'myOnloadCallback'
)
);
}
}
public
function
testDisplay
()
public
function
testDisplay
()
...
@@ -35,8 +37,8 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
...
@@ -35,8 +37,8 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
$simple
=
'<div data-sitekey="{site-key}" class="g-recaptcha"></div>'
;
$simple
=
'<div data-sitekey="{site-key}" class="g-recaptcha"></div>'
;
$withAttrs
=
'<div data-theme="light" data-sitekey="{site-key}" class="g-recaptcha"></div>'
;
$withAttrs
=
'<div data-theme="light" data-sitekey="{site-key}" class="g-recaptcha"></div>'
;
$this
->
assertEquals
(
$
this
->
captcha
->
display
(),
$simple
);
$this
->
assertEquals
(
$
simple
,
$this
->
captcha
->
display
()
);
$this
->
assertEquals
(
$
this
->
captcha
->
display
([
'data-theme'
=>
'light'
]),
$withAttrs
);
$this
->
assertEquals
(
$
withAttrs
,
$this
->
captcha
->
display
([
'data-theme'
=>
'light'
])
);
}
}
public
function
testdisplaySubmit
()
public
function
testdisplaySubmit
()
...
@@ -47,8 +49,18 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
...
@@ -47,8 +49,18 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
$simple
=
'<button data-callback="onSubmittest" data-sitekey="{site-key}" class="g-recaptcha"><span>submit</span></button>'
;
$simple
=
'<button data-callback="onSubmittest" data-sitekey="{site-key}" class="g-recaptcha"><span>submit</span></button>'
;
$withAttrs
=
'<button data-theme="light" class="g-recaptcha 123" data-callback="onSubmittest" data-sitekey="{site-key}"><span>submit123</span></button>'
;
$withAttrs
=
'<button data-theme="light" class="g-recaptcha 123" data-callback="onSubmittest" data-sitekey="{site-key}"><span>submit123</span></button>'
;
$this
->
assertEquals
(
$
this
->
captcha
->
displaySubmit
(
'test'
),
$simple
.
$javascript
);
$this
->
assertEquals
(
$
simple
.
$javascript
,
$this
->
captcha
->
displaySubmit
(
'test'
)
);
$withAttrsResult
=
$this
->
captcha
->
displaySubmit
(
'test'
,
'submit123'
,[
'data-theme'
=>
'light'
,
'class'
=>
'123'
]);
$withAttrsResult
=
$this
->
captcha
->
displaySubmit
(
'test'
,
'submit123'
,[
'data-theme'
=>
'light'
,
'class'
=>
'123'
]);
$this
->
assertEquals
(
$withAttrsResult
,
$withAttrs
.
$javascript
);
$this
->
assertEquals
(
$withAttrs
.
$javascript
,
$withAttrsResult
);
}
public
function
testdisplaySubmitWithCustomCallback
()
{
$this
->
assertTrue
(
$this
->
captcha
instanceof
NoCaptcha
);
$withAttrs
=
'<button data-theme="light" class="g-recaptcha 123" data-callback="onSubmitCustomCallback" data-sitekey="{site-key}"><span>submit123</span></button>'
;
$withAttrsResult
=
$this
->
captcha
->
displaySubmit
(
'test-custom'
,
'submit123'
,[
'data-theme'
=>
'light'
,
'class'
=>
'123'
,
'data-callback'
=>
'onSubmitCustomCallback'
]);
$this
->
assertEquals
(
$withAttrs
,
$withAttrsResult
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment