Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug #19854: Remove "option" subarray for "font_file" and "style"

  • Loading branch information...
commit 8c4a9a9caf5e8996a2581b0627c38732181e7319 1 parent b0ec66e
@cweiske authored
View
25 Text/CAPTCHA/Driver/Figlet.php
@@ -119,23 +119,34 @@ function init($options = array())
$this->_phrase = $options['phrase'];
}
- if (!empty($options['options']['style']) && is_array($options['options']['style'])) {
- $this->_style = $options['options']['style'];
+ if (isset($options['options']['style'])) {
+ //keep BC with older versions
+ $options['style'] = $options['options']['style'];
+ unset($options['options']['style']);
+ }
+ if (!empty($options['style']) && is_array($options['style'])) {
+ $this->_style = $options['style'];
}
if (empty($this->style['padding'])) {
$this->_style['padding'] = '5px';
}
+
+ if (isset($options['options']['font_file'])) {
+ //keep BC with older versions
+ $options['font_file'] = $options['options']['font_file'];
+ unset($options['options']['font_file']);
+ }
- if (!isset($options['options']['font_file'])
- || empty($options['options']['font_file'])
+ if (!isset($options['font_file'])
+ || empty($options['font_file'])
) {
$this->_error = PEAR::raiseError('Font file not passed.');
return $this->_error;
}
- if (is_array($options['options']['font_file'])) {
- $this->_font = $options['options']['font_file'][array_rand($options['options']['font_file'])];
+ if (is_array($options['font_file'])) {
+ $this->_font = $options['font_file'][array_rand($options['font_file'])];
} else {
- $this->_font = $options['options']['font_file'];
+ $this->_font = $options['font_file'];
}
}
}
View
47 tests/Text/CAPTCHA/Driver/FigletTest.php
@@ -7,7 +7,7 @@ public function setUp()
{
error_reporting(error_reporting() & ~E_STRICT);
}
-
+
public function testInitFontFileMissing()
{
$fig = Text_CAPTCHA::factory('Figlet');
@@ -36,7 +36,7 @@ public function testInitPhraseOptions()
'00000000', $fig->getPhrase()
);
}
-
+
public function testInitOldOptionFontFile()
{
$fig = Text_CAPTCHA::factory('Figlet');
@@ -52,10 +52,51 @@ public function testInitOldOptionFontFile()
);
$this->assertInternalType('string', $fig->getCAPTCHA());
}
-
+
+ public function testInitOptionFontFile()
+ {
+ //work around pear_config bug
+ error_reporting(error_reporting() & ~E_NOTICE);
+
+ $fig = Text_CAPTCHA::factory('Figlet');
+ $this->assertNotInstanceOf(
+ 'PEAR_Error',
+ $fig->init(
+ array(
+ 'font_file' => 'makisupa.flf'
+ )
+ )
+ );
+ $this->assertInternalType('string', $fig->getCAPTCHA());
+ }
+
+ public function testInitOptionFontStyle()
+ {
+ //work around pear_config bug
+ error_reporting(error_reporting() & ~E_NOTICE);
+
+ $fig = Text_CAPTCHA::factory('Figlet');
+ $this->assertNotInstanceOf(
+ 'PEAR_Error',
+ $fig->init(
+ array(
+ 'font_file' => 'makisupa.flf',
+ 'style' => array(
+ 'background-color: #FF8000'
+ )
+ )
+ )
+ );
+ $cap = $fig->getCAPTCHA();
+ $this->assertInternalType('string', $cap);
+ $this->assertContains('background-color: #FF8000;', $cap);
+ }
+
public function testInitOldOptionFontStyle()
{
+ //work around pear_config bug
error_reporting(error_reporting() & ~E_NOTICE);
+
$fig = Text_CAPTCHA::factory('Figlet');
$this->assertNotInstanceOf(
'PEAR_Error',
Please sign in to comment.
Something went wrong with that request. Please try again.