示例#1
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testCRUD()
 {
     Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
     $this->_model->setName('test');
     $crud = new Magento_Test_Entity($this->_model, array('name' => uniqid()));
     $crud->testCrud();
 }
示例#2
0
 /**
  * Upload the generated CAPTCHA to S3.
  *
  * @param string $id
  * @param string $word
  */
 protected function _generateImage($id, $word)
 {
     parent::_generateImage($id, $word);
     if ($this->getS3Helper()->checkS3Usage()) {
         $this->getS3Helper()->saveFile($this->getImgDir() . $this->getId() . $this->getSuffix());
     }
 }
示例#3
0
 /**
  * Generate captcha
  *
  * @return string
  */
 public function generate()
 {
     if (!Mage::helper('uaudio_storage')->isEnabled()) {
         return parent::generate();
     }
     $storageModel = Mage::getSingleton('core/file_storage')->getStorageModel();
     $id = Zend_Captcha_Word::generate();
     $tries = 5;
     // If there's already such file, try creating a new ID
     while ($tries-- && $storageModel->fileExists($this->getImgDir() . $id . $this->getSuffix())) {
         $id = $this->_generateRandomId();
         $this->_setId($id);
     }
     $this->_generateImage($id, $this->getWord());
     if (mt_rand(1, $this->getGcFreq()) == 1) {
         $this->_gc();
     }
     $imgFile = $this->getImgDir() . $id . $this->getSuffix();
     $storageModel->moveFile($imgFile, $imgFile);
     return $id;
 }
示例#4
0
 /**
  * @covers Mage_Captcha_Model_Zend::getWord
  */
 public function testGetWord()
 {
     $this->assertEquals($this->_object->getWord(), 'AbCdEf5');
     $this->_object->getSession()->setData(array('user_create_word' => array('data' => 'AbCdEf5', 'expires' => time() - 60)));
     $this->assertNull($this->_object->getWord());
 }