Commit 52ebe72b authored by Nguyen Van Anh's avatar Nguyen Van Anh Committed by GitHub

Merge pull request #89 from mmghv/pass-tests

Make tests pass
parents 1bafc19a a2f3fc12
...@@ -10,4 +10,6 @@ before_script: ...@@ -10,4 +10,6 @@ before_script:
- travis_retry composer self-update - travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction --dev - travis_retry composer install --prefer-source --no-interaction --dev
script: phpunit script:
- composer install
- vendor/bin/phpunit
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
"illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*", "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
"guzzlehttp/guzzle": "^6.2" "guzzlehttp/guzzle": "^6.2"
}, },
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Anhskohbo\\NoCaptcha\\": "src/" "Anhskohbo\\NoCaptcha\\": "src/"
......
...@@ -12,21 +12,27 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase ...@@ -12,21 +12,27 @@ class NoCaptchaTest extends PHPUnit_Framework_TestCase
$this->captcha = new NoCaptcha('{secret-key}', '{site-key}'); $this->captcha = new NoCaptcha('{secret-key}', '{site-key}');
} }
public function testDisplay() public function testJsLink()
{ {
$this->assertTrue($this->captcha instanceof NoCaptcha); $this->assertTrue($this->captcha instanceof NoCaptcha);
$simple ='<script src="https://www.google.com/recaptcha/api.js" async defer></script>'."\n". $simple = '<script src="https://www.google.com/recaptcha/api.js?" async defer></script>'."\n";
'<div class="g-recaptcha" data-sitekey="{site-key}"></div>'; $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";
$this->assertEquals($this->captcha->renderJs(), $simple);
$this->assertEquals($this->captcha->renderJs('vi'), $withLang);
$this->assertEquals($this->captcha->renderJs(null, true, 'myOnloadCallback'), $withCallback);
}
$withLang ='<script src="https://www.google.com/recaptcha/api.js?hl=vi" async defer></script>'."\n". public function testDisplay()
'<div class="g-recaptcha" data-sitekey="{site-key}"></div>'; {
$this->assertTrue($this->captcha instanceof NoCaptcha);
$withAttrs ='<script src="https://www.google.com/recaptcha/api.js" async defer></script>'."\n". $simple = '<div class="g-recaptcha" data-sitekey="{site-key}"></div>';
'<div class="g-recaptcha" data-theme="light" data-sitekey="{site-key}"></div>'; $withAttrs = '<div class="g-recaptcha" data-theme="light" data-sitekey="{site-key}"></div>';
$this->assertEquals($this->captcha->display(), $simple); $this->assertEquals($this->captcha->display(), $simple);
$this->assertEquals($this->captcha->display([], 'vi'), $withLang);
$this->assertEquals($this->captcha->display(['data-theme' => 'light']), $withAttrs); $this->assertEquals($this->captcha->display(['data-theme' => 'light']), $withAttrs);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment