|
|
@@ -219,6 +219,27 @@ class Zend_Captcha_ImageTest extends PHPUnit_Framework_TestCase
|
|
|
$this->assertFalse(file_exists($filename), "File $filename was found even after GC");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group ZF-10006
|
|
|
+ */
|
|
|
+ public function testCaptchaImageCleanupOnlyCaptchaFilesIdentifiedByTheirSuffix()
|
|
|
+ {
|
|
|
+ $this->element->render($this->getView());
|
|
|
+ $filename = $this->testDir."/".$this->captcha->getId().".png";
|
|
|
+ $this->assertTrue(file_exists($filename));
|
|
|
+ //Create other cache file
|
|
|
+ $otherFile = $this->testDir . "/zf10006.cache";
|
|
|
+ file_put_contents($otherFile, '');
|
|
|
+ $this->assertTrue(file_exists($otherFile));
|
|
|
+ $this->captcha->setExpiration(1);
|
|
|
+ $this->captcha->setGcFreq(1);
|
|
|
+ sleep(2);
|
|
|
+ $this->captcha->generate();
|
|
|
+ clearstatcache();
|
|
|
+ $this->assertFalse(file_exists($filename), "File $filename was found even after GC");
|
|
|
+ $this->assertTrue(file_exists($otherFile), "File $otherFile was not found after GC");
|
|
|
+ }
|
|
|
+
|
|
|
public function testGenerateReturnsId()
|
|
|
{
|
|
|
$id = $this->captcha->generate();
|