From 8461b86da04a737a49b38a82cc3c611c30270f12 Mon Sep 17 00:00:00 2001 From: Richard Jennings Date: Wed, 26 Jun 2013 12:08:38 +0100 Subject: [PATCH 1/3] Added test to ensure that an options argument to Zend\Captcha\ReCaptcha constructor with defined 'public_key' and/or 'private_key' key values are set on the ZendService\ReCaptcha\Recaptcha service via setPublicKey() and setPrivateKey(). --- tests/ZendTest/Captcha/ReCaptchaTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/ZendTest/Captcha/ReCaptchaTest.php b/tests/ZendTest/Captcha/ReCaptchaTest.php index 8f47a8b438e..6197e0c0acb 100644 --- a/tests/ZendTest/Captcha/ReCaptchaTest.php +++ b/tests/ZendTest/Captcha/ReCaptchaTest.php @@ -88,6 +88,19 @@ public function testSetAndGetPublicAndPrivateKeys() $this->assertSame($privKey, $captcha->getService()->getPrivateKey()); } + public function testSetAndGetRecaptchaServicePublicAndPrivateKeysFromOptions() + { + $publicKey = 'publicKey'; + $privateKey = 'privateKey'; + $options = array( + 'public_key' => $publicKey, + 'private_key' => $privateKey + ); + $captcha = new ReCaptcha($options); + $this->assertSame($publicKey, $captcha->getService()->getPublicKey()); + $this->assertSame($privateKey, $captcha->getService()->getPrivateKey()); + } + /** @group ZF-7654 */ public function testConstructorShouldAllowSettingLangOptionOnServiceObject() { From f4d4c15d244b4fa2f5eb49092a1113b361249ee5 Mon Sep 17 00:00:00 2001 From: Richard Jennings Date: Wed, 26 Jun 2013 12:15:24 +0100 Subject: [PATCH 2/3] Added setPrivateKey() and setPublicKey() calls to ZendService\ReCaptcha\ReCaptcha service if options provided to Zend\Captcha\ReCaptcha constructor contain a 'private_key' and/or 'public_key' key value. --- library/Zend/Captcha/ReCaptcha.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/Zend/Captcha/ReCaptcha.php b/library/Zend/Captcha/ReCaptcha.php index 64c51c9bec9..5fdbe931ac8 100644 --- a/library/Zend/Captcha/ReCaptcha.php +++ b/library/Zend/Captcha/ReCaptcha.php @@ -126,6 +126,14 @@ public function __construct($options = null) parent::__construct($options); if (!empty($options)) { + //set private key if specified + if (array_key_exists('private_key', $options)) { + $this->getService()->setPrivateKey($options['private_key']); + } + //set public key if specified + if (array_key_exists('public_key', $options)) { + $this->getService()->setPublicKey($options['public_key']); + } $this->setOptions($options); } } From 8e326c403eb5c5eb9af5fe1b8b15dbf9ebee4257 Mon Sep 17 00:00:00 2001 From: Mike Willbanks Date: Wed, 26 Jun 2013 07:55:32 -0700 Subject: [PATCH 3/3] Removed self-explanitory comments --- library/Zend/Captcha/ReCaptcha.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/Zend/Captcha/ReCaptcha.php b/library/Zend/Captcha/ReCaptcha.php index 5fdbe931ac8..64d2f56ff77 100644 --- a/library/Zend/Captcha/ReCaptcha.php +++ b/library/Zend/Captcha/ReCaptcha.php @@ -126,11 +126,9 @@ public function __construct($options = null) parent::__construct($options); if (!empty($options)) { - //set private key if specified if (array_key_exists('private_key', $options)) { $this->getService()->setPrivateKey($options['private_key']); } - //set public key if specified if (array_key_exists('public_key', $options)) { $this->getService()->setPublicKey($options['public_key']); }