Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'weierophinney/hotfix/captcha-factory-op…
Browse files Browse the repository at this point in the history
…tions'
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Factory.php
Expand Up @@ -81,7 +81,9 @@ public static function factory($options)
$class
));
}
$options = array();

unset($options['class']);

if (isset($options['options'])) {
$options = $options['options'];
}
Expand Down
11 changes: 11 additions & 0 deletions test/FactoryTest.php
Expand Up @@ -181,4 +181,15 @@ public function testCanCreateReCaptchaUsingShortName()
));
$this->assertInstanceOf('Zend\Captcha\ReCaptcha', $captcha);
}

public function testOptionsArePassedToCaptchaAdapter()
{
$captcha = Captcha\Factory::factory(array(
'class' => 'ZendTest\Captcha\TestAsset\MockCaptcha',
'options' => array(
'foo' => 'bar',
),
));
$this->assertEquals(array('foo' => 'bar'), $captcha->options);
}
}
71 changes: 71 additions & 0 deletions test/TestAsset/MockCaptcha.php
@@ -0,0 +1,71 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Captcha
* @subpackage UnitTest
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Captcha\TestAsset;

use Zend\Captcha\AdapterInterface;

/**
* @category Zend
* @package Zend_Captcha
* @subpackage UnitTest
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class MockCaptcha implements AdapterInterface
{
public $name;
public $options = array();

public function __construct($options = null)
{
$this->options = $options;
}

public function generate()
{
}

public function setName($name)
{
$this->name = $name;
}

public function getName()
{
return $this->name;
}

public function getHelperName()
{
return 'doctype';
}

public function isValid($value)
{
return true;
}

public function getMessages()
{
return array();
}
}

0 comments on commit f10d37b

Please sign in to comment.