Пример #1
0
 /**
  * Ensures format can be set and retrieved
  */
 public function testSetGetFormat()
 {
     $this->_validator->setFormat('\\d{1}');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('/^\\d{1}');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('/^\\d{1}$/');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('\\d{1}$/');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     try {
         $this->_validator->setFormat(null);
         $this->fail();
     } catch (Zend_Validate_Exception $e) {
         $this->assertContains('a not empty string', $e->getMessage());
     }
     try {
         $this->_validator->setFormat('');
         $this->fail();
     } catch (Zend_Validate_Exception $e) {
         $this->assertContains('a not empty string', $e->getMessage());
     }
 }
Пример #2
0
 /**
  * Ensures format can be set and retrieved
  */
 public function testSetGetFormat()
 {
     $this->_validator->setFormat('\\d{1}');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('/^\\d{1}');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('/^\\d{1}$/');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     $this->_validator->setFormat('\\d{1}$/');
     $this->assertEquals('/^\\d{1}$/', $this->_validator->getFormat());
     try {
         $this->_validator->setFormat(null);
         $this->fail();
     } catch (Validator\Exception $e) {
         $this->assertContains('has to be given', $e->getMessage());
     }
     try {
         $this->_validator->setFormat('');
         $this->fail();
     } catch (Validator\Exception $e) {
         $this->assertContains('has to be given', $e->getMessage());
     }
 }