コード例 #1
0
ファイル: BarcodeTest.php プロジェクト: netvlies/zf
 public function testInvalidChecksumAdapter()
 {
     // require_once dirname(__FILE__) . "/_files/MyBarcode1.php";
     $barcode = new Zend_Validate_Barcode('MyBarcode1');
     $this->assertFalse($barcode->isValid('0000000'));
     $this->assertTrue(array_key_exists('barcodeFailed', $barcode->getMessages()));
     $this->assertFalse($barcode->getAdapter()->checksum('0000000'));
 }
コード例 #2
0
ファイル: Upce.php プロジェクト: NerdGZ/icingaweb2
 /**
  * Particular validation for Upce barcode objects
  * (to suppress checksum character substitution)
  *
  * @param string $value
  * @param array  $options
  * @throws Zend_Barcode_Object_Exception
  */
 protected function _validateText($value, $options = array())
 {
     $validator = new Zend_Validate_Barcode(array('adapter' => 'upce', 'checksum' => false));
     $value = $this->_addLeadingZeros($value, true);
     if (!$validator->isValid($value)) {
         $message = implode("\n", $validator->getMessages());
         /**
          * @see Zend_Barcode_Object_Exception
          */
         throw new Zend_Barcode_Object_Exception($message);
     }
 }
コード例 #3
0
 /**
  * @group ZF-10116
  */
 public function testArrayLengthMessage()
 {
     $barcode = new Zend_Validate_Barcode('ean8');
     $this->assertFalse($barcode->isValid('123'));
     $message = $barcode->getMessages();
     $this->assertTrue(array_key_exists('barcodeInvalidLength', $message));
     $this->assertContains("length of 7/8 characters", $message['barcodeInvalidLength']);
 }
コード例 #4
0
ファイル: ObjectAbstract.php プロジェクト: vicfryzel/zf
 /**
  * Standard validation for most of barcode objects
  * @param string $value
  * @param array  $options
  */
 protected function _validateText($value, $options = array())
 {
     $validatorName = isset($options['validator']) ? $options['validator'] : $this->getType();
     $validator = new Zend_Validate_Barcode(array('adapter' => $validatorName, 'checksum' => false));
     $checksumCharacter = '';
     $withChecksum = false;
     if ($this->_mandatoryChecksum) {
         $checksumCharacter = $this->_substituteChecksumCharacter;
         $withChecksum = true;
     }
     $value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter;
     if (!$validator->isValid($value)) {
         $message = implode("\n", $validator->getMessages());
         /**
          * @see Zend_Barcode_Object_Exception
          */
         require_once 'Zend/Barcode/Object/Exception.php';
         throw new Zend_Barcode_Object_Exception($message);
     }
 }
コード例 #5
0
ファイル: Ean8.php プロジェクト: netixx/Stock
 /**
  * Particular validation for Ean8 barcode objects
  * (to suppress checksum character substitution)
  * @param string $value
  * @param array  $options
  */
 protected function _validateText($value, $options = array())
 {
     $validator = new Zend_Validate_Barcode(array('adapter' => 'ean8', 'checksum' => false));
     $value = $this->_addLeadingZeros($value, true);
     if (!$validator->isValid($value)) {
         $message = implode("\n", $validator->getMessages());
         /**
          * @see Zend_Barcode_Object_Exception
          */
         require_once PHP_LIBRARY_PATH . 'Zend/Barcode/Object/Exception.php';
         throw new Zend_Barcode_Object_Exception($message);
     }
 }