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

Commit

Permalink
Merge branch 'hotfix/ZF-11522' of https://github.com/adamlundrigan/zf2
Browse files Browse the repository at this point in the history
…into hotfix/zf-11522
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Dumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@
*/
class Dumb extends Word
{
/**
* CAPTCHA label
* @type string
*/
protected $_label = 'Please type this word backwards';

/**
* Set the label for the CAPTCHA
* @param string $label
*/
public function setLabel($label)
{
$this->_label = $label;
}

/**
* Retrieve the label for the CAPTCHA
* @return string
*/
public function getLabel()
{
return $this->_label;
}

/**
* Render the captcha
*
Expand All @@ -46,7 +70,7 @@ class Dumb extends Word
*/
public function render(Renderer $view = null, $element = null)
{
return 'Please type this word backwards: <b>'
return $this->getLabel() . ': <b>'
. strrev($this->getWord())
. '</b>';
}
Expand Down
29 changes: 29 additions & 0 deletions test/DumbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,33 @@ public function testRendersWordInReverse()
$this->assertContains(strrev($word), $html);
$this->assertNotContains($word, $html);
}

/**
* @group ZF-11522
*/
public function testDefaultLabelIsUsedWhenNoAlternateLabelSet()
{
$this->assertEquals('Please type this word backwards', $this->captcha->getLabel());
}

/**
* @group ZF-11522
*/
public function testChangeLabelViaSetterMethod()
{
$this->captcha->setLabel('Testing');
$this->assertEquals('Testing', $this->captcha->getLabel());
}

/**
* @group ZF-11522
*/
public function testRendersLabelUsingProvidedValue()
{
$this->captcha->setLabel('Testing 123');

$id = $this->captcha->generate('test');
$html = $this->captcha->render(new \Zend\View\Renderer\PhpRenderer);
$this->assertContains('Testing 123', $html);
}
}

0 comments on commit 60514d9

Please sign in to comment.