diff --git a/src/AbstractValidator.php b/src/AbstractValidator.php index 89a19c60e..83917422b 100644 --- a/src/AbstractValidator.php +++ b/src/AbstractValidator.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,7 +24,7 @@ namespace Zend\Validator; use Traversable, - Zend\Stdlib\IteratorToArray, + Zend\Stdlib\ArrayUtils, Zend\Translator, Zend\Validator\Exception\InvalidArgumentException; @@ -34,7 +34,7 @@ * @uses \Zend\Validator\Validator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class AbstractValidator implements Validator @@ -82,7 +82,7 @@ public function __construct($options = null) { // The abstract constructor allows no scalar values if ($options instanceof Traversable) { - $options = IteratorToArray::convert($options); + $options = ArrayUtils::iteratorToArray($options); } if (isset($this->_messageTemplates)) { @@ -112,7 +112,7 @@ public function getOption($option) } if (isset($this->options) && array_key_exists($option, $this->options)) { - return $this->options[$options]; + return $this->options[$option]; } throw new InvalidArgumentException("Invalid option '$option'"); diff --git a/src/Alnum.php b/src/Alnum.php index cbc868e79..fe1d6116e 100644 --- a/src/Alnum.php +++ b/src/Alnum.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Alnum extends AbstractValidator diff --git a/src/Alpha.php b/src/Alpha.php index e9c5cc470..cb834f190 100644 --- a/src/Alpha.php +++ b/src/Alpha.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Alpha extends AbstractValidator diff --git a/src/Barcode.php b/src/Barcode.php index df83dae05..e52bd2837 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Barcode extends AbstractValidator diff --git a/src/Barcode/AbstractAdapter.php b/src/Barcode/AbstractAdapter.php index f7697952d..685987016 100644 --- a/src/Barcode/AbstractAdapter.php +++ b/src/Barcode/AbstractAdapter.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\Adapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class AbstractAdapter implements Adapter diff --git a/src/Barcode/Adapter.php b/src/Barcode/Adapter.php index c3a5a0a31..06ec691b4 100644 --- a/src/Barcode/Adapter.php +++ b/src/Barcode/Adapter.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Adapter diff --git a/src/Barcode/Codabar.php b/src/Barcode/Codabar.php index cf12327c6..243428a8a 100644 --- a/src/Barcode/Codabar.php +++ b/src/Barcode/Codabar.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Codabar extends AbstractAdapter diff --git a/src/Barcode/Code128.php b/src/Barcode/Code128.php index 517c052dc..7ce9212d6 100644 --- a/src/Barcode/Code128.php +++ b/src/Barcode/Code128.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code128 extends AbstractAdapter diff --git a/src/Barcode/Code25.php b/src/Barcode/Code25.php index 2868af21b..60ea34c4b 100644 --- a/src/Barcode/Code25.php +++ b/src/Barcode/Code25.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code25 extends AbstractAdapter diff --git a/src/Barcode/Code25interleaved.php b/src/Barcode/Code25interleaved.php index 552c48d13..bf149313b 100644 --- a/src/Barcode/Code25interleaved.php +++ b/src/Barcode/Code25interleaved.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code25interleaved extends AbstractAdapter diff --git a/src/Barcode/Code39.php b/src/Barcode/Code39.php index 687e2d034..c2653e30f 100644 --- a/src/Barcode/Code39.php +++ b/src/Barcode/Code39.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code39 extends AbstractAdapter diff --git a/src/Barcode/Code39ext.php b/src/Barcode/Code39ext.php index 72b56f2d2..c2a7a679a 100644 --- a/src/Barcode/Code39ext.php +++ b/src/Barcode/Code39ext.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code39ext extends AbstractAdapter diff --git a/src/Barcode/Code93.php b/src/Barcode/Code93.php index 96e22ec9e..468dd6a6a 100644 --- a/src/Barcode/Code93.php +++ b/src/Barcode/Code93.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code93 extends AbstractAdapter diff --git a/src/Barcode/Code93ext.php b/src/Barcode/Code93ext.php index c56e63c00..559ee7e57 100644 --- a/src/Barcode/Code93ext.php +++ b/src/Barcode/Code93ext.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Code93ext extends AbstractAdapter diff --git a/src/Barcode/Ean12.php b/src/Barcode/Ean12.php index 376451f92..9014f5ae3 100644 --- a/src/Barcode/Ean12.php +++ b/src/Barcode/Ean12.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean12 extends AbstractAdapter diff --git a/src/Barcode/Ean13.php b/src/Barcode/Ean13.php index 3ca5d9fbc..9e556ac0b 100644 --- a/src/Barcode/Ean13.php +++ b/src/Barcode/Ean13.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean13 extends AbstractAdapter diff --git a/src/Barcode/Ean14.php b/src/Barcode/Ean14.php index ad4ec2dcc..f5da3841a 100644 --- a/src/Barcode/Ean14.php +++ b/src/Barcode/Ean14.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean14 extends AbstractAdapter diff --git a/src/Barcode/Ean18.php b/src/Barcode/Ean18.php index 95afff8c3..c7872b1b8 100644 --- a/src/Barcode/Ean18.php +++ b/src/Barcode/Ean18.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean18 extends AbstractAdapter diff --git a/src/Barcode/Ean2.php b/src/Barcode/Ean2.php index b2d5850c1..dc9c8ec5d 100644 --- a/src/Barcode/Ean2.php +++ b/src/Barcode/Ean2.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean2 extends AbstractAdapter diff --git a/src/Barcode/Ean5.php b/src/Barcode/Ean5.php index d9185ee6e..9edaff152 100644 --- a/src/Barcode/Ean5.php +++ b/src/Barcode/Ean5.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean5 extends AbstractAdapter diff --git a/src/Barcode/Ean8.php b/src/Barcode/Ean8.php index ae4ab9c77..3087d9ddb 100644 --- a/src/Barcode/Ean8.php +++ b/src/Barcode/Ean8.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ean8 extends AbstractAdapter diff --git a/src/Barcode/Gtin12.php b/src/Barcode/Gtin12.php index 28e3876f2..bcf72bdf7 100644 --- a/src/Barcode/Gtin12.php +++ b/src/Barcode/Gtin12.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Gtin12 extends AbstractAdapter diff --git a/src/Barcode/Gtin13.php b/src/Barcode/Gtin13.php index 0cc73fa88..896adb626 100644 --- a/src/Barcode/Gtin13.php +++ b/src/Barcode/Gtin13.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Gtin13 extends AbstractAdapter diff --git a/src/Barcode/Gtin14.php b/src/Barcode/Gtin14.php index b5c2ef0e6..389f2f372 100644 --- a/src/Barcode/Gtin14.php +++ b/src/Barcode/Gtin14.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Gtin14 extends AbstractAdapter diff --git a/src/Barcode/Identcode.php b/src/Barcode/Identcode.php index 331f41bda..8b9e6f69f 100644 --- a/src/Barcode/Identcode.php +++ b/src/Barcode/Identcode.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Identcode extends AbstractAdapter diff --git a/src/Barcode/Intelligentmail.php b/src/Barcode/Intelligentmail.php index b82e07383..d4d64e114 100644 --- a/src/Barcode/Intelligentmail.php +++ b/src/Barcode/Intelligentmail.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Intelligentmail extends AbstractAdapter diff --git a/src/Barcode/Issn.php b/src/Barcode/Issn.php index d82721f40..6df8fe307 100644 --- a/src/Barcode/Issn.php +++ b/src/Barcode/Issn.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Issn extends AbstractAdapter diff --git a/src/Barcode/Itf14.php b/src/Barcode/Itf14.php index fdd21563f..3ec872ffd 100644 --- a/src/Barcode/Itf14.php +++ b/src/Barcode/Itf14.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Itf14 extends AbstractAdapter diff --git a/src/Barcode/Leitcode.php b/src/Barcode/Leitcode.php index 21c690df3..d50767a9d 100644 --- a/src/Barcode/Leitcode.php +++ b/src/Barcode/Leitcode.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Leitcode extends AbstractAdapter diff --git a/src/Barcode/Planet.php b/src/Barcode/Planet.php index d6348c907..bfdfeb76a 100644 --- a/src/Barcode/Planet.php +++ b/src/Barcode/Planet.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Planet extends AbstractAdapter diff --git a/src/Barcode/Postnet.php b/src/Barcode/Postnet.php index fe2121c51..592da1bb2 100644 --- a/src/Barcode/Postnet.php +++ b/src/Barcode/Postnet.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Postnet extends AbstractAdapter diff --git a/src/Barcode/Royalmail.php b/src/Barcode/Royalmail.php index b85355242..52b06b6a3 100644 --- a/src/Barcode/Royalmail.php +++ b/src/Barcode/Royalmail.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Royalmail extends AbstractAdapter diff --git a/src/Barcode/Sscc.php b/src/Barcode/Sscc.php index d3a74c0ca..d43b9df7c 100644 --- a/src/Barcode/Sscc.php +++ b/src/Barcode/Sscc.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Sscc extends AbstractAdapter diff --git a/src/Barcode/Upca.php b/src/Barcode/Upca.php index e74f77f4e..4ac22b133 100644 --- a/src/Barcode/Upca.php +++ b/src/Barcode/Upca.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Upca extends AbstractAdapter diff --git a/src/Barcode/Upce.php b/src/Barcode/Upce.php index 1e3d52e51..fc5b6305c 100644 --- a/src/Barcode/Upce.php +++ b/src/Barcode/Upce.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\Barcode\AbstractAdapter * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Upce extends AbstractAdapter diff --git a/src/Between.php b/src/Between.php index 2f65918c6..ff027eccc 100644 --- a/src/Between.php +++ b/src/Between.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Between extends AbstractValidator diff --git a/src/Callback.php b/src/Callback.php index 93a6e1f1d..70be2e697 100644 --- a/src/Callback.php +++ b/src/Callback.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Callback extends AbstractValidator diff --git a/src/CreditCard.php b/src/CreditCard.php index 1c8a10981..3639d5c90 100644 --- a/src/CreditCard.php +++ b/src/CreditCard.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace Zend\Validator; +use Traversable, + Zend\Stdlib\ArrayUtils; + /** * @uses \Zend\Validator\AbstractValidator * @uses \Zend\Validator\Callback * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class CreditCard extends AbstractValidator @@ -80,7 +80,7 @@ class CreditCard extends AbstractValidator * * @var array */ - protected $_cardName = array( + protected $cardName = array( 0 => self::AMERICAN_EXPRESS, 1 => self::DINERS_CLUB, 2 => self::DINERS_CLUB_US, @@ -99,7 +99,7 @@ class CreditCard extends AbstractValidator * * @var array */ - protected $_cardLength = array( + protected $cardLength = array( self::AMERICAN_EXPRESS => array(15), self::DINERS_CLUB => array(14), self::DINERS_CLUB_US => array(16), @@ -118,7 +118,7 @@ class CreditCard extends AbstractValidator * * @var array */ - protected $_cardType = array( + protected $cardType = array( self::AMERICAN_EXPRESS => array('34', '37'), self::DINERS_CLUB => array('300', '301', '302', '303', '304', '305', '36'), self::DINERS_CLUB_US => array('54', '55'), @@ -153,12 +153,12 @@ class CreditCard extends AbstractValidator /** * Constructor * - * @param string|array $type OPTIONAL Type of CCI to allow + * @param string|array|Traversable $type OPTIONAL Type of CCI to allow */ public function __construct($options = array()) { - if ($options instanceof \Zend\Config\Config) { - $options = $options->toArray(); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); } else if (!is_array($options)) { $options = func_get_args(); $temp['type'] = array_shift($options); @@ -174,11 +174,14 @@ public function __construct($options = array()) } $this->setType($options['type']); + unset($options['type']); + if (array_key_exists('service', $options)) { $this->setService($options['service']); + unset($options['service']); } - parent::__construct(); + parent::__construct($options); } /** @@ -188,26 +191,26 @@ public function __construct($options = array()) */ public function getType() { - return $this->_type; + return $this->options['type']; } /** * Sets CCIs which are accepted by validation * - * @param string|array $type Type to allow for validation - * @return \Zend\Validator\CreditCard Provides a fluid interface + * @param string|array $type Type to allow for validation + * @return CreditCard Provides a fluid interface */ public function setType($type) { - $this->_type = array(); + $this->options['type'] = array(); return $this->addType($type); } /** * Adds a CCI to be accepted by validation * - * @param string|array $type Type to allow for validation - * @return \Zend\Validator\CreditCard Provides a fluid interface + * @param string|array $type Type to allow for validation + * @return CreditCard Provides a fluid interface */ public function addType($type) { @@ -216,12 +219,12 @@ public function addType($type) } foreach($type as $typ) { - if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->_type)) { - $this->_type[] = $typ; + if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->options['type'])) { + $this->options['type'][] = $typ; } if (($typ == self::ALL)) { - $this->_type = array_keys($this->_cardLength); + $this->options['type'] = array_keys($this->cardLength); } } @@ -241,7 +244,9 @@ public function getService() /** * Sets a new callback for service validation * - * @param unknown_type $service + * @param callable $service + * @return CreditCard + * @throws Exception\InvalidArgumentException on invalid service callback */ public function setService($service) { @@ -278,10 +283,10 @@ public function isValid($value) $foundp = false; $foundl = false; foreach ($types as $type) { - foreach ($this->_cardType[$type] as $prefix) { + foreach ($this->cardType[$type] as $prefix) { if (substr($value, 0, strlen($prefix)) == $prefix) { $foundp = true; - if (in_array($length, $this->_cardLength[$type])) { + if (in_array($length, $this->cardLength[$type])) { $foundl = true; break 2; } diff --git a/src/Date.php b/src/Date.php index 348b3dbc7..5d3d5c530 100644 --- a/src/Date.php +++ b/src/Date.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,17 +22,18 @@ * @namespace */ namespace Zend\Validator; -use Zend\Date as ZendDate; + +use Traversable, + Zend\Date as ZendDate, + Zend\Locale\Format, + Zend\Locale\Locale, + Zend\Registry, + Zend\Stdlib\ArrayUtils; /** - * @uses \Zend\Date\Date - * @uses \Zend\Locale\Locale - * @uses \Zend\Locale\Format - * @uses \Zend\Registry - * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Date extends AbstractValidator @@ -56,7 +57,7 @@ class Date extends AbstractValidator * @var array */ protected $_messageVariables = array( - 'format' => '_format' + 'format' => 'format' ); /** @@ -64,26 +65,26 @@ class Date extends AbstractValidator * * @var string|null */ - protected $_format; + protected $format; /** * Optional locale * * @var string|\Zend\Locale\Locale|null */ - protected $_locale; + protected $locale; /** * Sets validator options * - * @param string|\Zend\Config\Config $options OPTIONAL + * @param string|array|Traversable $options OPTIONAL * @return void */ public function __construct($options = array()) { - if ($options instanceof \Zend\Config\Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } elseif (!is_array($options)) { $options = func_get_args(); $temp['format'] = array_shift($options); if (!empty($options)) { @@ -98,35 +99,37 @@ public function __construct($options = array()) } if (!array_key_exists('locale', $options)) { - if (\Zend\Registry::isRegistered('Zend_Locale')) { - $options['locale'] = \Zend\Registry::get('Zend_Locale'); + if (Registry::isRegistered('Zend_Locale')) { + $options['locale'] = Registry::get('Zend_Locale'); } } if (array_key_exists('locale', $options)) { $this->setLocale($options['locale']); } + + parent::__construct($options); } /** * Returns the locale option * - * @return string|\Zend\Locale\Locale|null + * @return string|Locale|null */ public function getLocale() { - return $this->_locale; + return $this->locale; } /** * Sets the locale option * - * @param string|\Zend\Locale\Locale $locale - * @return \Zend\Validator\Date provides a fluent interface + * @param string|Locale $locale + * @return Date provides a fluent interface */ public function setLocale($locale = null) { - $this->_locale = \Zend\Locale\Locale::findLocale($locale); + $this->locale = Locale::findLocale($locale); return $this; } @@ -137,7 +140,7 @@ public function setLocale($locale = null) */ public function getFormat() { - return $this->_format; + return $this->format; } /** @@ -148,7 +151,7 @@ public function getFormat() */ public function setFormat($format = null) { - $this->_format = $format; + $this->format = $format; return $this; } @@ -157,24 +160,30 @@ public function setFormat($format = null) * If optional $format or $locale is set the date format is checked * according to Zend_Date, see Zend_Date::isDate() * - * @param string|array|\Zend\Date\Date $value + * @param string|array|ZendDate $value * @return boolean */ public function isValid($value) { - if (!is_string($value) && !is_int($value) && !is_float($value) && - !is_array($value) && !($value instanceof ZendDate\Date)) { + if (!is_string($value) + && !is_int($value) + && !is_float($value) + && !is_array($value) + && !($value instanceof ZendDate\Date) + ) { $this->error(self::INVALID); return false; } $this->setValue($value); - if (($this->_format !== null) || ($this->_locale !== null) - || is_array($value) || $value instanceof Date\Date + if (($this->format !== null) + || ($this->locale !== null) + || is_array($value) + || $value instanceof ZendDate\Date ) { - if (!ZendDate\Date::isDate($value, $this->_format, $this->_locale)) { - if ($this->_checkFormat($value) === false) { + if (!ZendDate\Date::isDate($value, $this->format, $this->locale)) { + if ($this->checkFormat($value) === false) { $this->error(self::FALSEFORMAT); } else { $this->error(self::INVALID_DATE); @@ -183,9 +192,9 @@ public function isValid($value) } } else { if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { - $this->_format = 'yyyy-MM-dd'; + $this->format = 'yyyy-MM-dd'; $this->error(self::FALSEFORMAT); - $this->_format = null; + $this->format = null; return false; } @@ -206,14 +215,18 @@ public function isValid($value) * @param string $value Date to check * @return boolean False when date does not fit the format */ - private function _checkFormat($value) + private function checkFormat($value) { try { - $parsed = \Zend\Locale\Format::getDate($value, array( - 'date_format' => $this->_format, 'format_type' => 'iso', - 'fix_date' => false)); - if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false) and - (strpos(strtoupper($this->_format), 'YYYY') === false))) { + $parsed = Format::getDate((string) $value, array( + 'date_format' => $this->format, + 'format_type' => 'iso', + 'fix_date' => false, + )); + if (isset($parsed['year']) + && ((strpos(strtoupper($this->format), 'YY') !== false) + && (strpos(strtoupper($this->format), 'YYYY') === false)) + ) { $parsed['year'] = ZendDate\Date::getFullYear($parsed['year']); } } catch (\Exception $e) { @@ -221,34 +234,36 @@ private function _checkFormat($value) return false; } - if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false)) and - (!isset($parsed['year']))) { + if (((strpos($this->format, 'Y') !== false) || (strpos($this->format, 'y') !== false)) + && (!isset($parsed['year'])) + ) { // Year expected but not found return false; } - if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) { + if ((strpos($this->format, 'M') !== false) && (!isset($parsed['month']))) { // Month expected but not found return false; } - if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) { + if ((strpos($this->format, 'd') !== false) && (!isset($parsed['day']))) { // Day expected but not found return false; } - if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false)) and - (!isset($parsed['hour']))) { + if (((strpos($this->format, 'H') !== false) || (strpos($this->format, 'h') !== false)) + && (!isset($parsed['hour'])) + ) { // Hour expected but not found return false; } - if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) { + if ((strpos($this->format, 'm') !== false) && (!isset($parsed['minute']))) { // Minute expected but not found return false; } - if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) { + if ((strpos($this->format, 's') !== false) && (!isset($parsed['second']))) { // Second expected but not found return false; } diff --git a/src/Db/AbstractDb.php b/src/Db/AbstractDb.php index 4242afc71..04c3e1a1a 100644 --- a/src/Db/AbstractDb.php +++ b/src/Db/AbstractDb.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -37,7 +37,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class AbstractDb extends AbstractValidator @@ -107,6 +107,8 @@ abstract class AbstractDb extends AbstractValidator */ public function __construct($options = null) { + parent::__construct(); + if ($options instanceof DBSelect) { $this->setSelect($options); return; diff --git a/src/Db/NoRecordExists.php b/src/Db/NoRecordExists.php index b17785b10..a7acc76c7 100644 --- a/src/Db/NoRecordExists.php +++ b/src/Db/NoRecordExists.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @uses \Zend\Validator\Db\AbstractDb * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class NoRecordExists extends AbstractDb diff --git a/src/Db/RecordExists.php b/src/Db/RecordExists.php index 1d60c4687..0c2d898f3 100644 --- a/src/Db/RecordExists.php +++ b/src/Db/RecordExists.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @uses \Zend\Validator\Db\AbstractDb * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class RecordExists extends AbstractDb diff --git a/src/Digits.php b/src/Digits.php index 0dea309ec..141c14020 100644 --- a/src/Digits.php +++ b/src/Digits.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Digits extends AbstractValidator diff --git a/src/EmailAddress.php b/src/EmailAddress.php index 12ccff05c..275aee47e 100644 --- a/src/EmailAddress.php +++ b/src/EmailAddress.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @uses \Zend\Validator\Hostname * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class EmailAddress extends AbstractValidator @@ -312,17 +312,17 @@ protected function isReserved($host){ foreach ($host as $server) { // Search for 0.0.0.0/8, 10.0.0.0/8, 127.0.0.0/8 - if (!preg_match('/^(0|10|127)(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){3}$/', $host) && + if (!preg_match('/^(0|10|127)(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){3}$/', $server) && // Search for 172.16.0.0.12 - !preg_match('/^172\.(1[6-9]|2[0-9]|3[0-1])(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $host) && + !preg_match('/^172\.(1[6-9]|2[0-9]|3[0-1])(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $server) && // Search for 198.18.0.0/15 - !preg_match('/^198\.(1[8-9])(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $host) && + !preg_match('/^198\.(1[8-9])(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $server) && // Search for 128.0.0.0/16, 169.254.0.0/16, 191.255.0.0/16, 192.168.0.0/16 - !preg_match('/^(128\.0|169\.254|191\.255|192\.168)(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $host) && + !preg_match('/^(128\.0|169\.254|191\.255|192\.168)(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){2}$/', $server) && // Search for 192.0.0.0/24, 192.0.2.0/24, 192.88.99.0/24, 198.51.100.0/24, 203.0.113.0/24, 223.255.255.0/24 - !preg_match('/^(192\.0\.(0|2)|192\.88\.99|198\.51\.100|203\.0\.113|223\.255\.255)\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$/', $host) && + !preg_match('/^(192\.0\.(0|2)|192\.88\.99|198\.51\.100|203\.0\.113|223\.255\.255)\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$/', $server) && // Search for 224.0.0.0/4, 240.0.0.0/4 - !preg_match('/^(2(2[4-9]|[3-4][0-9]|5[0-5]))(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){3}$/', $host)) { + !preg_match('/^(2(2[4-9]|[3-4][0-9]|5[0-5]))(\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))){3}$/', $server)) { return false; } } diff --git a/src/Exception.php b/src/Exception.php index 1113c0813..a219a2662 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Exception diff --git a/src/File/Count.php b/src/File/Count.php index f5c6fa5fd..9b5720bab 100644 --- a/src/File/Count.php +++ b/src/File/Count.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Count extends Validator\AbstractValidator diff --git a/src/File/Crc32.php b/src/File/Crc32.php index 5c11fd709..d22c813ba 100644 --- a/src/File/Crc32.php +++ b/src/File/Crc32.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @uses \Zend\Validator\File\Hash * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Crc32 extends Hash diff --git a/src/File/ExcludeExtension.php b/src/File/ExcludeExtension.php index 0a2f6c619..52d226106 100644 --- a/src/File/ExcludeExtension.php +++ b/src/File/ExcludeExtension.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\File\Extension * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ExcludeExtension extends Extension diff --git a/src/File/ExcludeMimeType.php b/src/File/ExcludeMimeType.php index cd784c32f..5c930d200 100644 --- a/src/File/ExcludeMimeType.php +++ b/src/File/ExcludeMimeType.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ * @uses \Zend\Validator\File\MimeType * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ExcludeMimeType extends MimeType @@ -63,50 +63,51 @@ public function isValid($value, $file = null) // Is file readable ? if (!Loader::isReadable($value)) { - return $this->_throw($file, self::NOT_READABLE); + return $this->createError($file, self::NOT_READABLE); } $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->_finfo))) { - $this->_finfo = @finfo_open($const, $mimefile); + if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) { + $this->finfo = finfo_open($const, $mimefile); } - if (empty($this->_finfo)) { - $this->_finfo = @finfo_open($const); + if (empty($this->finfo)) { + $this->finfo = finfo_open($const); } - $this->_type = null; - if (!empty($this->_finfo)) { - $this->_type = finfo_file($this->_finfo, $value); + $this->type = null; + if (!empty($this->finfo)) { + $this->type = finfo_file($this->finfo, $value); } } - if (empty($this->_type) && - (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { - $this->_type = mime_content_type($value); + if (empty($this->type) && + (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) + ) { + $this->type = mime_content_type($value); } - if (empty($this->_type) && $this->getHeaderCheck()) { - $this->_type = $file['type']; + if (empty($this->type) && $this->getHeaderCheck()) { + $this->type = $file['type']; } - if (empty($this->_type)) { - return $this->_throw($file, self::NOT_DETECTED); + if (empty($this->type)) { + return $this->createError($file, self::NOT_DETECTED); } $mimetype = $this->getMimeType(true); - if (in_array($this->_type, $mimetype)) { - return $this->_throw($file, self::FALSE_TYPE); + if (in_array($this->type, $mimetype)) { + return $this->createError($file, self::FALSE_TYPE); } - $types = explode('/', $this->_type); - $types = array_merge($types, explode('-', $this->_type)); - $types = array_merge($types, explode(';', $this->_type)); - foreach($mimetype as $mime) { + $types = explode('/', $this->type); + $types = array_merge($types, explode('-', $this->type)); + $types = array_merge($types, explode(';', $this->type)); + foreach ($mimetype as $mime) { if (in_array($mime, $types)) { - return $this->_throw($file, self::FALSE_TYPE); + return $this->createError($file, self::FALSE_TYPE); } } diff --git a/src/File/Exists.php b/src/File/Exists.php index fd6f2e03c..71f565b75 100644 --- a/src/File/Exists.php +++ b/src/File/Exists.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Exists extends Validator\AbstractValidator diff --git a/src/File/Extension.php b/src/File/Extension.php index 92a6938c0..618efd0f2 100644 --- a/src/File/Extension.php +++ b/src/File/Extension.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Extension extends \Zend\Validator\AbstractValidator diff --git a/src/File/FilesSize.php b/src/File/FilesSize.php index 001aa50e4..4b60cf0a3 100644 --- a/src/File/FilesSize.php +++ b/src/File/FilesSize.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class FilesSize extends Size diff --git a/src/File/Hash.php b/src/File/Hash.php index b82491a1e..e847f2616 100644 --- a/src/File/Hash.php +++ b/src/File/Hash.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Hash extends Validator\AbstractValidator diff --git a/src/File/ImageSize.php b/src/File/ImageSize.php index eef0da92e..81f698653 100644 --- a/src/File/ImageSize.php +++ b/src/File/ImageSize.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ImageSize extends Validator\AbstractValidator diff --git a/src/File/IsCompressed.php b/src/File/IsCompressed.php index ddad2b3f8..d0aac1969 100644 --- a/src/File/IsCompressed.php +++ b/src/File/IsCompressed.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace Zend\Validator\File; +use Traversable, + Zend\Stdlib\ArrayUtils; + /** * Validator which checks if the file already exists in the directory * * @uses \Zend\Validator\File\MimeType * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class IsCompressed extends MimeType @@ -93,28 +93,14 @@ public function __construct($options = array()) 'multipart/x-gzip', ); - if (is_array($options) && array_key_exists('magicFile', $options)) { - $this->setMagicFile($options['magicFile']); - unset($options['magicFile']); - } - - if (is_array($options) && array_key_exists('enableHeaderCheck', $options)) { - $this->enableHeaderCheck($options['enableHeaderCheck']); - unset($options['enableHeaderCheck']); - } - - if (is_array($options) && !array_key_exists('mimeType', $options)) { - $options['mimeType'] = $options; + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); } if (empty($options)) { $options = array('mimeType' => $default); } - if (!is_array($options)) { - $options = array('mimeType' => $options); - } - parent::__construct($options); } @@ -126,14 +112,16 @@ public function __construct($options = array()) * @param string $errorType * @return false */ - protected function _throw($file, $errorType) + protected function createError($file, $errorType) { if ($file !== null) { if (is_array($file)) { if(array_key_exists('name', $file)) { - $this->value = basename($file['name']); + $file = $file['name']; } - } else if (is_string($file)) { + } + + if (is_string($file)) { $this->value = basename($file); } } diff --git a/src/File/IsImage.php b/src/File/IsImage.php index ce1bac076..2f8d1c598 100644 --- a/src/File/IsImage.php +++ b/src/File/IsImage.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace Zend\Validator\File; +use Traversable, + Zend\Stdlib\ArrayUtils; + /** * Validator which checks if the file already exists in the directory * * @uses \Zend\Validator\File\MimeType * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class IsImage extends MimeType @@ -53,7 +53,7 @@ class IsImage extends MimeType /** * Sets validator options * - * @param string|array|\Zend\Config\Config $mimetype + * @param string|array|Traversable $mimetype * @return void */ public function __construct($options = array()) @@ -118,28 +118,14 @@ public function __construct($options = array()) 'image/x-xpmi', ); - if (is_array($options) && array_key_exists('magicFile', $options)) { - $this->setMagicFile($options['magicFile']); - unset($options['magicFile']); - } - - if (is_array($options) && array_key_exists('enableHeaderCheck', $options)) { - $this->enableHeaderCheck($options['enableHeaderCheck']); - unset($options['enableHeaderCheck']); - } - - if (is_array($options) && !array_key_exists('mimeType', $options)) { - $options['mimeType'] = $options; + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); } if (empty($options)) { $options = array('mimeType' => $default); } - if (!is_array($options)) { - $options = array('mimeType' => $options); - } - parent::__construct($options); } @@ -151,14 +137,16 @@ public function __construct($options = array()) * @param string $errorType * @return false */ - protected function _throw($file, $errorType) + protected function createError($file, $errorType) { if ($file !== null) { if (is_array($file)) { if(array_key_exists('name', $file)) { - $this->value = basename($file['name']); + $file = $file['name']; } - } else if (is_string($file)) { + } + + if (is_string($file)) { $this->value = basename($file); } } diff --git a/src/File/Md5.php b/src/File/Md5.php index e7e6b6cff..64976f9c4 100644 --- a/src/File/Md5.php +++ b/src/File/Md5.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @uses \Zend\Validator\File\Hash * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Md5 extends Hash diff --git a/src/File/MimeType.php b/src/File/MimeType.php index abae603f8..7b18254b8 100644 --- a/src/File/MimeType.php +++ b/src/File/MimeType.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,24 +23,21 @@ */ namespace Zend\Validator\File; -use Zend\Config\Config, +use Traversable, Zend\Loader, - Zend\Validator, + Zend\Stdlib\ArrayUtils, + Zend\Validator\AbstractValidator, Zend\Validator\Exception; /** * Validator for the mime type of a file * - * @uses finfo - * @uses \Zend\Loader - * @uses \Zend\Validator\AbstractValidator - * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class MimeType extends Validator\AbstractValidator +class MimeType extends AbstractValidator { /**#@+ * @const Error type constants @@ -63,26 +60,26 @@ class MimeType extends Validator\AbstractValidator * @var array */ protected $_messageVariables = array( - 'type' => '_type' + 'type' => 'type' ); /** * @var string */ - protected $_type; + protected $type; /** * Finfo object to use * * @var resource */ - protected $_finfo; + protected $finfo; /** * If no environment variable 'MAGIC' is set, try and autodiscover it based on common locations * @var array */ - protected $_magicFiles = array( + protected $magicFiles = array( '/usr/share/misc/magic', '/usr/share/misc/magic.mime', '/usr/share/misc/magic.mgc', @@ -119,10 +116,11 @@ class MimeType extends Validator\AbstractValidator */ public function __construct($options = null) { - if ($options instanceof Config) { - $options = $options->toArray(); - } else if (is_string($options)) { - $options = explode(',', $options); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); + } elseif (is_string($options)) { + $this->setMimeType($options); + $options = array(); } if (isset($options['magicFile'])) { @@ -135,8 +133,19 @@ public function __construct($options = null) unset($options['enableHeaderCheck']); } - if (!array_key_exists('mimeType', $options)) { - $options = array('mimeType' => $options); + if (array_key_exists('mimeType', $options)) { + $this->setMimeType($options['mimeType']); + unset($options['mimeType']); + } + + // Handle cases where mimetypes are interspersed with options, or + // options are simply an array of mime types + foreach (array_keys($options) as $key) { + if (!is_int($key)) { + continue; + } + $this->addMimeType($options[$key]); + unset($options[$key]); } parent::__construct($options); @@ -154,14 +163,14 @@ public function getMagicFile() if (!empty($magic)) { $this->setMagicFile($magic); } elseif (!(@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1)) { - foreach ($this->_magicFiles as $file) { + foreach ($this->magicFiles as $file) { // supressing errors which are thrown due to openbase_dir restrictions try { $this->setMagicFile($file); if ($this->options['magicFile'] !== null) { break; } - } catch (Validator\Exception $e) { + } catch (Exception $e) { // Intentionally, catch and fall through } } @@ -182,8 +191,8 @@ public function getMagicFile() * if false, the default MAGIC file from PHP will be used * * @param string $file - * @throws \Zend\Validator\Exception When finfo can not read the magicfile - * @return \Zend\Validator\File\MimeType Provides fluid interface + * @throws Exception When finfo can not read the magicfile + * @return MimeType Provides fluid interface */ public function setMagicFile($file) { @@ -193,15 +202,21 @@ public function setMagicFile($file) $this->options['magicFile'] = null; } else if (!(class_exists('finfo', false))) { $this->options['magicFile'] = null; - throw new Exception\InvalidArgumentException('Magicfile can not be set. There is no finfo extension installed'); + throw new Exception\InvalidArgumentException('Magicfile can not be set; there is no finfo extension installed'); } else if (!is_file($file) || !is_readable($file)) { - throw new Exception\InvalidArgumentException('The given magicfile can not be read'); + throw new Exception\InvalidArgumentException(sprintf( + 'The given magicfile ("%s") could not be read', + $file + )); } else { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - $this->_finfo = @finfo_open($const, $file); - if (empty($this->_finfo)) { - $this->_finfo = null; - throw new Exception\InvalidArgumentException('The given magicfile is not accepted by finfo'); + $this->finfo = @finfo_open($const, $file); + if (empty($this->finfo)) { + $this->finfo = null; + throw new Exception\InvalidArgumentException(sprintf( + 'The given magicfile ("%s") could not be used by ext/finfo', + $file + )); } else { $this->options['magicFile'] = $file; } @@ -276,7 +291,7 @@ public function getMimeType($asArray = false) * Sets the mimetypes * * @param string|array $mimetype The mimetypes to validate - * @return \Zend\Validator\File\Extension Provides a fluent interface + * @return MimeType Provides a fluent interface */ public function setMimeType($mimetype) { @@ -289,7 +304,7 @@ public function setMimeType($mimetype) * Adds the mimetypes * * @param string|array $mimetype The mimetypes to add for validation - * @return \Zend\Validator\File\Extension Provides a fluent interface + * @return MimeType Provides a fluent interface */ public function addMimeType($mimetype) { @@ -347,54 +362,54 @@ public function isValid($value, $file = null) // Is file readable ? if (!Loader::isReadable($value)) { - return $this->_throw($file, self::NOT_READABLE); + return $this->createError($file, self::NOT_READABLE); } $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->_finfo))) { - $this->_finfo = @finfo_open($const, $mimefile); + if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) { + $this->finfo = @finfo_open($const, $mimefile); } - if (empty($this->_finfo)) { - $this->_finfo = @finfo_open($const); + if (empty($this->finfo)) { + $this->finfo = @finfo_open($const); } - $this->_type = null; - if (!empty($this->_finfo)) { - $this->_type = finfo_file($this->_finfo, $value); + $this->type = null; + if (!empty($this->finfo)) { + $this->type = finfo_file($this->finfo, $value); } } - if (empty($this->_type) && + if (empty($this->type) && (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { - $this->_type = mime_content_type($value); + $this->type = mime_content_type($value); } - if (empty($this->_type) && $this->getHeaderCheck()) { - $this->_type = $file['type']; + if (empty($this->type) && $this->getHeaderCheck()) { + $this->type = $file['type']; } - if (empty($this->_type)) { - return $this->_throw($file, self::NOT_DETECTED); + if (empty($this->type)) { + return $this->createError($file, self::NOT_DETECTED); } $mimetype = $this->getMimeType(true); - if (in_array($this->_type, $mimetype)) { + if (in_array($this->type, $mimetype)) { return true; } - $types = explode('/', $this->_type); - $types = array_merge($types, explode('-', $this->_type)); - $types = array_merge($types, explode(';', $this->_type)); + $types = explode('/', $this->type); + $types = array_merge($types, explode('-', $this->type)); + $types = array_merge($types, explode(';', $this->type)); foreach($mimetype as $mime) { if (in_array($mime, $types)) { return true; } } - return $this->_throw($file, self::FALSE_TYPE); + return $this->createError($file, self::FALSE_TYPE); } /** @@ -404,14 +419,16 @@ public function isValid($value, $file = null) * @param string $errorType * @return false */ - protected function _throw($file, $errorType) + protected function createError($file, $errorType) { if ($file !== null) { if (is_array($file)) { if(array_key_exists('name', $file)) { - $this->value = basename($file['name']); + $file = $file['name']; } - } else if (is_string($file)) { + } + + if (is_string($file)) { $this->value = basename($file); } } diff --git a/src/File/NotExists.php b/src/File/NotExists.php index 18a00c51e..bcbc2e28e 100644 --- a/src/File/NotExists.php +++ b/src/File/NotExists.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @uses \Zend\Validator\File\Exists * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class NotExists extends Exists diff --git a/src/File/Sha1.php b/src/File/Sha1.php index 69a5ff1bd..6dc2941bf 100644 --- a/src/File/Sha1.php +++ b/src/File/Sha1.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ * @uses \Zend\Validator\File\Hash * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Sha1 extends Hash diff --git a/src/File/Size.php b/src/File/Size.php index fb1ddad51..168861926 100644 --- a/src/File/Size.php +++ b/src/File/Size.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Size extends Validator\AbstractValidator diff --git a/src/File/Upload.php b/src/File/Upload.php index b6bad1203..5075c7732 100644 --- a/src/File/Upload.php +++ b/src/File/Upload.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Upload extends \Zend\Validator\AbstractValidator @@ -81,7 +81,7 @@ class Upload extends \Zend\Validator\AbstractValidator */ public function __construct($options = array()) { - if (!array_key_exists('files', $options)) { + if (is_array($options) && !array_key_exists('files', $options)) { $options = array('files' => $options); } diff --git a/src/File/WordCount.php b/src/File/WordCount.php index 65f71cc6c..f8c2a0e9a 100644 --- a/src/File/WordCount.php +++ b/src/File/WordCount.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\File\Count * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class WordCount extends Count diff --git a/src/Float.php b/src/Float.php index e39b84d63..dcb4317f9 100644 --- a/src/Float.php +++ b/src/Float.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Float extends AbstractValidator diff --git a/src/GreaterThan.php b/src/GreaterThan.php index c1a55cbff..ebf593864 100644 --- a/src/GreaterThan.php +++ b/src/GreaterThan.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class GreaterThan extends AbstractValidator @@ -103,6 +103,8 @@ public function __construct($options = null) $this->setMin($options['min']) ->setInclusive($options['inclusive']); + + parent::__construct(); } /** diff --git a/src/Hex.php b/src/Hex.php index cfe9d4acf..339c17671 100644 --- a/src/Hex.php +++ b/src/Hex.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Hex extends AbstractValidator diff --git a/src/Hostname.php b/src/Hostname.php index 6792ff781..ff522ce3d 100644 --- a/src/Hostname.php +++ b/src/Hostname.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -37,7 +37,7 @@ * @uses \Zend\Validator\Ip * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Hostname extends AbstractValidator @@ -110,7 +110,7 @@ class Hostname extends AbstractValidator 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tel', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', - 'ye', 'yt', 'yu', 'za', 'zm', 'zw' + 'xxx', 'ye', 'yt', 'yu', 'za', 'zm', 'zw' ); /** diff --git a/src/Hostname/Biz.php b/src/Hostname/Biz.php index 4368f1cb7..21a8cc0bf 100644 --- a/src/Hostname/Biz.php +++ b/src/Hostname/Biz.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/src/Hostname/Cn.php b/src/Hostname/Cn.php index 7bf2c9fd5..7a7f1283c 100644 --- a/src/Hostname/Cn.php +++ b/src/Hostname/Cn.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/src/Hostname/Com.php b/src/Hostname/Com.php index 61b2d12a5..003bf07b0 100644 --- a/src/Hostname/Com.php +++ b/src/Hostname/Com.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/src/Hostname/Jp.php b/src/Hostname/Jp.php index 24f0fade0..151eb23ba 100644 --- a/src/Hostname/Jp.php +++ b/src/Hostname/Jp.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( diff --git a/src/Iban.php b/src/Iban.php index f6e009d46..8c17c1ef7 100644 --- a/src/Iban.php +++ b/src/Iban.php @@ -14,27 +14,23 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace Zend\Validator; -use Zend; -use Zend\Locale; + +use Traversable, + Zend\Locale\Locale, + Zend\Registry, + Zend\Stdlib\ArrayUtils; /** * Validates IBAN Numbers (International Bank Account Numbers) * - * @uses \Zend\Locale\Locale - * @uses \Zend\Registry - * @uses \Zend\Validator\AbstractValidator - * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Iban extends AbstractValidator @@ -57,16 +53,16 @@ class Iban extends AbstractValidator /** * Optional locale * - * @var string|\Zend\Locale\Locale|null + * @var string|Locale|null */ - protected $_locale; + protected $locale; /** * IBAN regexes by region * * @var array */ - protected $_ibanregex = array( + protected $ibanregex = array( 'AD' => '/^AD[0-9]{2}[0-9]{8}[A-Z0-9]{12}$/', 'AT' => '/^AT[0-9]{2}[0-9]{5}[0-9]{11}$/', 'BA' => '/^BA[0-9]{2}[0-9]{6}[0-9]{10}$/', @@ -111,60 +107,65 @@ class Iban extends AbstractValidator /** * Sets validator options * - * @param string|Zend_Config|\Zend\Locale\Locale $locale OPTIONAL + * @param null|string|Locale|array|Traversable $locale OPTIONAL * @return void */ public function __construct($locale = null) { - if ($locale instanceof \Zend\Config\Config) { - $locale = $locale->toArray(); + $options = array(); + if ($locale instanceof Traversable) { + $locale = ArrayUtils::iteratorToArray($locale); } if (is_array($locale)) { + $options = $locale; if (array_key_exists('locale', $locale)) { - $locale = $locale['locale']; + $locale = $locale['locale']; + unset($options['locale']); } else { $locale = null; } } if (empty($locale) && ($locale !== false)) { - if (\Zend\Registry::isRegistered('Zend_Locale')) { - $locale = \Zend\Registry::get('Zend_Locale'); + if (Registry::isRegistered('Zend_Locale')) { + $locale = Registry::get('Zend_Locale'); } } if ($locale !== null) { $this->setLocale($locale); } + + parent::__construct($options); } /** * Returns the locale option * - * @return string|\Zend\Locale\Locale|null + * @return string|Locale|null */ public function getLocale() { - return $this->_locale; + return $this->locale; } /** * Sets the locale option * - * @param string|\Zend\Locale\Locale $locale - * @return \Zend\Validator\Date provides a fluent interface + * @param string|Locale $locale + * @return Iban provides a fluent interface */ public function setLocale($locale = null) { if ($locale !== false) { - $locale = Locale\Locale::findLocale($locale); + $locale = Locale::findLocale($locale); if (strlen($locale) < 4) { throw new Exception\InvalidArgumentException('Region must be given for IBAN validation'); } } - $this->_locale = $locale; + $this->locale = $locale; return $this; } @@ -179,20 +180,20 @@ public function isValid($value) $value = strtoupper($value); $this->setValue($value); - if (empty($this->_locale)) { + if (empty($this->locale)) { $region = substr($value, 0, 2); } else { - $region = new Locale\Locale($this->_locale); + $region = new Locale($this->locale); $region = $region->getRegion(); } - if (!array_key_exists($region, $this->_ibanregex)) { + if (!array_key_exists($region, $this->ibanregex)) { $this->setValue($region); $this->error(self::NOTSUPPORTED); return false; } - if (!preg_match($this->_ibanregex[$region], $value)) { + if (!preg_match($this->ibanregex[$region], $value)) { $this->error(self::FALSEFORMAT); return false; } diff --git a/src/Identical.php b/src/Identical.php index 8e5a6e83f..5b86cc08c 100644 --- a/src/Identical.php +++ b/src/Identical.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,11 +23,14 @@ */ namespace Zend\Validator; +use Traversable, + Zend\Stdlib\ArrayUtils; + /** * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Identical extends AbstractValidator @@ -52,16 +55,16 @@ class Identical extends AbstractValidator * @var array */ protected $_messageVariables = array( - 'token' => '_tokenString' + 'token' => 'tokenString' ); /** * Original token against which to validate * @var string */ - protected $_tokenString; - protected $_token; - protected $_strict = true; + protected $tokenString; + protected $token; + protected $strict = true; /** * Sets validator options @@ -71,8 +74,8 @@ class Identical extends AbstractValidator */ public function __construct($token = null) { - if ($token instanceof \Zend\Config\Config) { - $token = $token->toArray(); + if ($token instanceof Traversable) { + $token = ArrayUtils::iteratorToArray($token); } if (is_array($token) && array_key_exists('token', $token)) { @@ -95,7 +98,7 @@ public function __construct($token = null) */ public function getToken() { - return $this->_token; + return $this->token; } /** @@ -106,8 +109,8 @@ public function getToken() */ public function setToken($token) { - $this->_tokenString = (string) $token; - $this->_token = $token; + $this->tokenString = (string) $token; + $this->token = $token; return $this; } @@ -118,7 +121,7 @@ public function setToken($token) */ public function getStrict() { - return $this->_strict; + return $this->strict; } /** @@ -128,7 +131,7 @@ public function getStrict() */ public function setStrict($strict) { - $this->_strict = (boolean) $strict; + $this->strict = (boolean) $strict; return $this; } diff --git a/src/InArray.php b/src/InArray.php index 845104e58..cbbbe4fca 100644 --- a/src/InArray.php +++ b/src/InArray.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class InArray extends AbstractValidator @@ -103,6 +103,8 @@ public function __construct($options = null) if (array_key_exists('recursive', $options)) { $this->setRecursive($options['recursive']); } + + parent::__construct(); } /** diff --git a/src/Int.php b/src/Int.php index b64cdcb76..27aac6cba 100644 --- a/src/Int.php +++ b/src/Int.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,7 @@ * @uses \Zend\Validator\AbstractValidator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Int extends AbstractValidator @@ -77,6 +77,8 @@ public function __construct($locale = null) if ($locale !== null) { $this->setLocale($locale); } + + parent::__construct(); } /** diff --git a/src/Ip.php b/src/Ip.php index efbbdb21e..ff71f7f07 100644 --- a/src/Ip.php +++ b/src/Ip.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,12 +23,14 @@ */ namespace Zend\Validator; +use Traversable; + /** * @uses \Zend\Validator\AbstractValidator * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Ip extends AbstractValidator @@ -76,6 +78,8 @@ public function __construct($options = array()) $options += $this->_options; $this->setOptions($options); + + parent::__construct(); } /** diff --git a/src/Isbn.php b/src/Isbn.php index f20976061..a0e9663c4 100644 --- a/src/Isbn.php +++ b/src/Isbn.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Isbn extends AbstractValidator diff --git a/src/LessThan.php b/src/LessThan.php index a230fcc27..86154827b 100644 --- a/src/LessThan.php +++ b/src/LessThan.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class LessThan extends AbstractValidator @@ -105,6 +105,8 @@ public function __construct($options = null) $this->setMax($options['max']) ->setInclusive($options['inclusive']); + + parent::__construct(); } /** diff --git a/src/NotEmpty.php b/src/NotEmpty.php index a9f1ed184..74c39027e 100644 --- a/src/NotEmpty.php +++ b/src/NotEmpty.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class NotEmpty extends AbstractValidator diff --git a/src/PostCode.php b/src/PostCode.php index 533dc494a..55230fb23 100644 --- a/src/PostCode.php +++ b/src/PostCode.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class PostCode extends AbstractValidator diff --git a/src/Regex.php b/src/Regex.php index 84c5ef690..29c6667fc 100644 --- a/src/Regex.php +++ b/src/Regex.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,12 +23,15 @@ */ namespace Zend\Validator; +use Traversable, + Zend\Stdlib\ArrayUtils; + /** * @uses \Zend\Validator\AbstractValidator * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Regex extends AbstractValidator @@ -50,7 +53,7 @@ class Regex extends AbstractValidator * @var array */ protected $_messageVariables = array( - 'pattern' => '_pattern' + 'pattern' => 'pattern' ); /** @@ -58,30 +61,38 @@ class Regex extends AbstractValidator * * @var string */ - protected $_pattern; + protected $pattern; /** * Sets validator options * - * @param string|\Zend\Config\Config $pattern + * @param string|Traversable $pattern * @throws \Zend\Validator\Exception On missing 'pattern' parameter * @return void */ public function __construct($pattern) { - if ($pattern instanceof \Zend\Config\Config) { - $pattern = $pattern->toArray(); + if (is_string($pattern)) { + $this->setPattern($pattern); + parent::__construct(array()); + return; + } + + if ($pattern instanceof Traversable) { + $pattern = ArrayUtils::iteratorToArray($pattern); + } + + if (!is_array($pattern)) { + throw new Exception\InvalidArgumentException('Invalid options provided to constructor'); } - if (is_array($pattern)) { - if (array_key_exists('pattern', $pattern)) { - $pattern = $pattern['pattern']; - } else { - throw new Exception\InvalidArgumentException("Missing option 'pattern'"); - } + if (!array_key_exists('pattern', $pattern)) { + throw new Exception\InvalidArgumentException("Missing option 'pattern'"); } - $this->setPattern($pattern); + $this->setPattern($pattern['pattern']); + unset($pattern['pattern']); + parent::__construct($pattern); } /** @@ -91,7 +102,7 @@ public function __construct($pattern) */ public function getPattern() { - return $this->_pattern; + return $this->pattern; } /** @@ -103,11 +114,11 @@ public function getPattern() */ public function setPattern($pattern) { - $this->_pattern = (string) $pattern; - $status = @preg_match($this->_pattern, "Test"); + $this->pattern = (string) $pattern; + $status = @preg_match($this->pattern, "Test"); if (false === $status) { - throw new Exception\InvalidArgumentException("Internal error while using the pattern '$this->_pattern'"); + throw new Exception\InvalidArgumentException("Internal error parsing the pattern '{$this->pattern}'"); } return $this; @@ -128,7 +139,7 @@ public function isValid($value) $this->setValue($value); - $status = @preg_match($this->_pattern, $value); + $status = @preg_match($this->pattern, $value); if (false === $status) { $this->error(self::ERROROUS); return false; diff --git a/src/Sitemap/Changefreq.php b/src/Sitemap/Changefreq.php index e8628b73f..7fc731c8b 100644 --- a/src/Sitemap/Changefreq.php +++ b/src/Sitemap/Changefreq.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Changefreq extends \Zend\Validator\AbstractValidator diff --git a/src/Sitemap/Lastmod.php b/src/Sitemap/Lastmod.php index 4a6935e72..a3d510133 100644 --- a/src/Sitemap/Lastmod.php +++ b/src/Sitemap/Lastmod.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Lastmod extends \Zend\Validator\AbstractValidator diff --git a/src/Sitemap/Loc.php b/src/Sitemap/Loc.php index 3e3a83317..6446c06d9 100644 --- a/src/Sitemap/Loc.php +++ b/src/Sitemap/Loc.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Loc extends \Zend\Validator\AbstractValidator diff --git a/src/Sitemap/Priority.php b/src/Sitemap/Priority.php index aacc6cf31..bd3d501a3 100644 --- a/src/Sitemap/Priority.php +++ b/src/Sitemap/Priority.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Validate * @subpackage Sitemap - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Priority extends \Zend\Validator\AbstractValidator diff --git a/src/StaticValidator.php b/src/StaticValidator.php index a57afece5..d023c36fe 100644 --- a/src/StaticValidator.php +++ b/src/StaticValidator.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class StaticValidator diff --git a/src/StringLength.php b/src/StringLength.php index 51fc9c958..491614bc9 100644 --- a/src/StringLength.php +++ b/src/StringLength.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @uses \Zend\Validator\Exception * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class StringLength extends AbstractValidator diff --git a/src/Validator.php b/src/Validator.php index 15ba5eabe..0a201f028 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ /** * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Validator diff --git a/src/ValidatorBroker.php b/src/ValidatorBroker.php index f0cb85f49..20b74c37f 100644 --- a/src/ValidatorBroker.php +++ b/src/ValidatorBroker.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ValidatorBroker extends PluginSpecBroker diff --git a/src/ValidatorChain.php b/src/ValidatorChain.php index bc0f8d43d..9cb561d97 100644 --- a/src/ValidatorChain.php +++ b/src/ValidatorChain.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @uses \Zend\Validator\Validator * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ValidatorChain implements Validator diff --git a/src/ValidatorLoader.php b/src/ValidatorLoader.php index 431fa8894..88d89c9b4 100644 --- a/src/ValidatorLoader.php +++ b/src/ValidatorLoader.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -27,7 +27,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class ValidatorLoader extends PluginClassLoader diff --git a/test/AbstractTest.php b/test/AbstractTest.php index c5d5fb63c..d46ba41cc 100644 --- a/test/AbstractTest.php +++ b/test/AbstractTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,7 @@ * @package Zend_Validator * @subpackage UnitTests * @group Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class AbstractTest extends \PHPUnit_Framework_TestCase diff --git a/test/AlnumTest.php b/test/AlnumTest.php index c51034a23..ca1a2e911 100644 --- a/test/AlnumTest.php +++ b/test/AlnumTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -165,4 +166,40 @@ public function testIntegerValidation() { $this->assertTrue($this->_validator->isValid(1)); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/AlphaTest.php b/test/AlphaTest.php index 29a3d8b2f..6448770d5 100644 --- a/test/AlphaTest.php +++ b/test/AlphaTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,6 +24,8 @@ */ namespace ZendTest\Validator; +use ReflectionClass; + /** * Test helper */ @@ -37,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -131,4 +133,40 @@ public function testNonStringValidation() { $this->assertFalse($this->_validator->isValid(array(1 => 1))); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index 3e533b8a1..953d06462 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator\Barcode; +use Zend\Validator\Barcode, + ReflectionClass; /** * \Zend\Validator\Barcode @@ -32,7 +33,7 @@ * @package Zend_Validator * @subpackage UnitTests * @uses Zend_Validator_Barcode - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -469,4 +470,40 @@ public function testEan13ContainsOnlyNumeric() $barcode = new Barcode('ean13'); $this->assertFalse($barcode->isValid('3RH1131-1BB40')); } + + public function testEqualsMessageTemplates() + { + $validator = new Barcode('code25'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Barcode('code25'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/BetweenTest.php b/test/BetweenTest.php index b0b089a0d..8d164e2e6 100644 --- a/test/BetweenTest.php +++ b/test/BetweenTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -118,4 +119,40 @@ public function testGetInclusive() $validator = new Validator\Between(array('min' => 1, 'max' => 10)); $this->assertEquals(true, $validator->getInclusive()); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\Between(array('min' => 1, 'max' => 10)); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Between(array('min' => 1, 'max' => 10)); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/CallbackTest.php b/test/CallbackTest.php index 932f80cad..214a2f1da 100644 --- a/test/CallbackTest.php +++ b/test/CallbackTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,13 +23,14 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -90,6 +91,42 @@ public function testAddingValueOptions() $this->assertTrue($valid->isValid('test', 'something')); } + public function testEqualsMessageTemplates() + { + $validator = new Validator\Callback(array($this, 'objectCallback')); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Callback(array($this, 'objectCallback')); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } + public function objectCallback($value) { return true; diff --git a/test/CreditCardTest.php b/test/CreditCardTest.php index eb41b334d..c9e476256 100644 --- a/test/CreditCardTest.php +++ b/test/CreditCardTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,8 +23,9 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; -use Zend\Config; +use Zend\Validator, + Zend\Config, + ReflectionClass; /** * Test helper @@ -38,30 +39,32 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ class CreditCardTest extends \PHPUnit_Framework_TestCase { + public static function basicValues() + { + return array( + array('4111111111111111', true), + array('5404000000000001', true), + array('374200000000004', true), + array('4444555566667777', false), + array('ABCDEF', false), + ); + } + /** * Ensures that the validator follows expected behavior * - * @return void + * @dataProvider basicValues */ - public function testBasic() + public function testBasic($input, $expected) { $validator = new Validator\CreditCard(); - $valuesExpected = array( - '4111111111111111' => true, - '5404000000000001' => true, - '374200000000004' => true, - '4444555566667777' => false, - 'ABCDEF' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $validator->isValid($input), 'Test failed at ' . $input); - } + $this->assertEquals($expected, $validator->isValid($input)); } /** @@ -115,24 +118,26 @@ public function testGetSetType() ); } + public static function visaValues() + { + return array( + array('4111111111111111', true), + array('5404000000000001', false), + array('374200000000004', false), + array('4444555566667777', false), + array('ABCDEF', false), + ); + } + /** * Test specific provider * - * @return void + * @dataProvider visaValues */ - public function testProvider() + public function testProvider($input, $expected) { $validator = new Validator\CreditCard(Validator\CreditCard::VISA); - $valuesExpected = array( - '4111111111111111' => true, - '5404000000000001' => false, - '374200000000004' => false, - '4444555566667777' => false, - 'ABCDEF' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $validator->isValid($input)); - } + $this->assertEquals($expected, $validator->isValid($input)); } /** @@ -146,52 +151,56 @@ public function testIsValidWithNonString() $this->assertFalse($validator->isValid(array('something'))); } + public static function serviceValues() + { + return array( + array('4111111111111111', false), + array('5404000000000001', false), + array('374200000000004', false), + array('4444555566667777', false), + array('ABCDEF', false), + ); + } + /** * Test service class with invalid validation * - * @return void + * @dataProvider serviceValues */ - public function testServiceClass() + public function testServiceClass($input, $expected) { $validator = new Validator\CreditCard(); $this->assertEquals(null, $validator->getService()); - $validator->setService(array('\ZendTest\Validator\CreditCardTest', 'staticCallback')); - $valuesExpected = array( - '4111111111111111' => false, - '5404000000000001' => false, - '374200000000004' => false, - '4444555566667777' => false, - 'ABCDEF' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $validator->isValid($input)); - } + $validator->setService(array('ZendTest\Validator\CreditCardTest', 'staticCallback')); + $this->assertEquals($expected, $validator->isValid($input)); + } + + public static function optionsValues() + { + return array( + array('4111111111111111', false), + array('5404000000000001', false), + array('374200000000004', false), + array('4444555566667777', false), + array('ABCDEF', false), + ); } /** * Test non string input * - * @return void + * @dataProvider optionsValues */ - public function testConstructionWithOptions() + public function testConstructionWithOptions($input, $expected) { $validator = new Validator\CreditCard( array( 'type' => Validator\CreditCard::VISA, - 'service' => array('\ZendTest\Validator\CreditCardTest', 'staticCallback') + 'service' => array('ZendTest\Validator\CreditCardTest', 'staticCallback') ) ); - $valuesExpected = array( - '4111111111111111' => false, - '5404000000000001' => false, - '374200000000004' => false, - '4444555566667777' => false, - 'ABCDEF' => false - ); - foreach ($valuesExpected as $input => $result) { - $this->assertEquals($result, $validator->isValid($input)); - } + $this->assertEquals($expected, $validator->isValid($input)); } /** @@ -205,7 +214,7 @@ public function testInvalidServiceClass() $this->assertEquals(null, $validator->getService()); $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'Invalid callback given'); - $validator->setService(array('\ZendTest\Validator\CreditCardTest', 'nocallback')); + $validator->setService(array('ZendTest\Validator\CreditCardTest', 'nocallback')); } /** @@ -229,11 +238,11 @@ public function testConfigObject() */ public function testOptionalConstructorParameterByConfigObject() { - $config = new Config\Config(array('type' => 'Visa', 'service' => array('\ZendTest\Validator\CreditCardTest', 'staticCallback'))); + $config = new Config\Config(array('type' => 'Visa', 'service' => array('ZendTest\Validator\CreditCardTest', 'staticCallback'))); $validator = new Validator\CreditCard($config); $this->assertEquals(array('Visa'), $validator->getType()); - $this->assertEquals(array('\ZendTest\Validator\CreditCardTest', 'staticCallback'), $validator->getService()); + $this->assertEquals(array('ZendTest\Validator\CreditCardTest', 'staticCallback'), $validator->getService()); } /** @@ -243,9 +252,9 @@ public function testOptionalConstructorParameterByConfigObject() */ public function testOptionalConstructorParameter() { - $validator = new Validator\CreditCard('Visa', array('\ZendTest\Validator\CreditCardTest', 'staticCallback')); + $validator = new Validator\CreditCard('Visa', array('ZendTest\Validator\CreditCardTest', 'staticCallback')); $this->assertEquals(array('Visa'), $validator->getType()); - $this->assertEquals(array('\ZendTest\Validator\CreditCardTest', 'staticCallback'), $validator->getService()); + $this->assertEquals(array('ZendTest\Validator\CreditCardTest', 'staticCallback'), $validator->getService()); } /** @@ -257,6 +266,42 @@ public function testMultiInstitute() { $message = $validator->getMessages(); $this->assertContains('not from an allowed institute', current($message)); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\CreditCard(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\CreditCard(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } public static function staticCallback($value) { diff --git a/test/DateTest.php b/test/DateTest.php index 0a9de738f..ff190c911 100644 --- a/test/DateTest.php +++ b/test/DateTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,8 +23,11 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; -use Zend\Date; + +use Zend\Validator, + Zend\Date, + Zend\Registry, + ReflectionClass; /** * Test helper @@ -38,7 +41,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -65,7 +68,9 @@ class DateTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->_validator = new Validator\Date(); + Registry::_unsetInstance(); + $this->_errorOccurred = false; + $this->_validator = new Validator\Date(); } /** @@ -148,15 +153,7 @@ public function testUseManualFormat() $this->assertFalse($this->_validator->setFormat('dd/MM/yyyy')->isValid('2008/10/22')); $this->assertTrue($this->_validator->setFormat('dd/MM/yy')->isValid('22/10/08')); $this->assertFalse($this->_validator->setFormat('dd/MM/yy')->isValid('22/10')); - set_error_handler(array($this, 'errorHandlerIgnore')); - $result = $this->_validator->setFormat('s')->isValid(0); - restore_error_handler(); - if (!$this->_errorOccurred) { - $this->assertTrue($result); - } else { - $this->markTestSkipped('Affected by bug described in ZF-2789'); - } - $this->_errorOccurred = false; + $this->assertFalse($this->_validator->setFormat('s')->isValid(0)); } /** @@ -231,6 +228,7 @@ public function testUsingApplicationLocale() } /** + * @group fml * ZF-7630 */ public function testDateObjectVerification() @@ -264,4 +262,40 @@ public function errorHandlerIgnore($errno, $errstr, $errfile, $errline, array $e { $this->_errorOccurred = true; } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/Db/NoRecordExistsTest.php b/test/Db/NoRecordExistsTest.php index 213dfc249..606f8ec0a 100644 --- a/test/Db/NoRecordExistsTest.php +++ b/test/Db/NoRecordExistsTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,14 +26,15 @@ use Zend\Db\Table\AbstractTable, Zend\Validator\Db\RecordExists as RecordExistsValidator, - Zend\Validator\Db\NoRecordExists as NoRecordExistsValidator; + Zend\Validator\Db\NoRecordExists as NoRecordExistsValidator, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -223,4 +224,40 @@ public function testCreatesQueryBasedOnNamedOrPositionalAvailablity() $wherePart = $validator->getSelect()->getPart('where'); $this->assertEquals('("field1" = :value)', $wherePart[0]); } + + public function testEqualsMessageTemplates() + { + $validator = new NoRecordExistsValidator('users', 'field1'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new NoRecordExistsValidator('users', 'field1'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/Db/RecordExistsTest.php b/test/Db/RecordExistsTest.php index 945c4b614..f1df4db19 100644 --- a/test/Db/RecordExistsTest.php +++ b/test/Db/RecordExistsTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -25,13 +25,14 @@ namespace ZendTest\Validator\Db; use Zend\Db\Table\AbstractTable, - Zend\Validator\Db\RecordExists as RecordExistsValidator; + Zend\Validator\Db\RecordExists as RecordExistsValidator, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -212,4 +213,40 @@ public function testExcludeConstructor() $validator = new RecordExistsValidator('users', 'field1', 'id != 1'); $this->assertTrue($validator->isValid('value3')); } + + public function testEqualsMessageTemplates() + { + $validator = new RecordExistsValidator('users', 'field1'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new RecordExistsValidator('users', 'field1'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/Db/TestAsset/MockHasResult.php b/test/Db/TestAsset/MockHasResult.php index 4b88ec413..be3424614 100644 --- a/test/Db/TestAsset/MockHasResult.php +++ b/test/Db/TestAsset/MockHasResult.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Validate * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class MockHasResult extends AbstractAdapter diff --git a/test/Db/TestAsset/MockNoResult.php b/test/Db/TestAsset/MockNoResult.php index 775d49378..31c0233ee 100644 --- a/test/Db/TestAsset/MockNoResult.php +++ b/test/Db/TestAsset/MockNoResult.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validate * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Validate * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class MockNoResult extends AbstractAdapter diff --git a/test/DigitsTest.php b/test/DigitsTest.php index 777029570..f24ecf863 100644 --- a/test/DigitsTest.php +++ b/test/DigitsTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -127,4 +128,40 @@ public function testNonStringValidation() { $this->assertFalse($this->_validator->isValid(array(1 => 1))); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/EmailAddressTest.php b/test/EmailAddressTest.php index b9a3ad596..c19d02ba6 100644 --- a/test/EmailAddressTest.php +++ b/test/EmailAddressTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,14 +23,15 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; -use Zend\Validator\Hostname; +use Zend\Validator, + Zend\Validator\Hostname, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -591,4 +592,101 @@ public function testGetMXRecord() $result = $validator->getMXRecord(); $this->assertTrue(!empty($result)); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } + + /** + * @group ZF2-130 + */ + public function testUseMxCheckBasicValid() + { + $validator = new Validator\EmailAddress(array( + 'useMxCheck' => true, + 'useDeepMxCheck' => true + )); + + $emailAddresses = array( + 'bob@gmail.com', + 'bob.jones@bbc.co.uk', + 'bob.jones.smythe@bbc.co.uk', + 'BoB@aol.com', + 'bobjones@nist.gov', + "B.O'Callaghan@usmc.mil", + 'bob+jones@nic.us', + 'bob+jones@dailymail.co.uk', + 'bob@teaparty.uk.com', + 'bob@thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com' + ); + + foreach ($emailAddresses as $input) { + $this->assertTrue($validator->isValid($input), "$input failed to pass validation:\n" + . implode("\n", $validator->getMessages())); + } + } + + /** + * @group ZF2-130 + */ + public function testUseMxRecordsBasicInvalid() { + $validator = new Validator\EmailAddress(array( + 'useMxCheck' => true, + 'useDeepMxCheck' => true + )); + + $emailAddresses = array( + '', + 'bob + + @domain.com', + 'bob jones@domain.com', + '.bobJones@studio24.com', + 'bobJones.@studio24.com', + 'bob.Jones.@studio24.com', + '"bob%jones@domain.com', + 'bob@verylongdomainsupercalifragilisticexpialidociousaspoonfulofsugar.com', + 'bob+domain.com', + 'bob.domain.com', + 'bob @domain.com', + 'bob@ domain.com', + 'bob @ domain.com', + 'Abc..123@example.com' + ); + foreach ($emailAddresses as $input) { + $this->assertFalse($validator->isValid($input), implode("\n", $this->_validator->getMessages()) . $input); + } + } } diff --git a/test/File/CountTest.php b/test/File/CountTest.php index c0f02a3f6..4703e53d6 100644 --- a/test/File/CountTest.php +++ b/test/File/CountTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/Crc32Test.php b/test/File/Crc32Test.php index 5eef2d6f9..dacaadbaa 100644 --- a/test/File/Crc32Test.php +++ b/test/File/Crc32Test.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/ExcludeExtensionTest.php b/test/File/ExcludeExtensionTest.php index ed714c83b..6f05c6c79 100644 --- a/test/File/ExcludeExtensionTest.php +++ b/test/File/ExcludeExtensionTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/ExcludeMimeTypeTest.php b/test/File/ExcludeMimeTypeTest.php index 78988cf7b..5d6b8f78e 100644 --- a/test/File/ExcludeMimeTypeTest.php +++ b/test/File/ExcludeMimeTypeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator\File; -use Zend\Validator\File; + +use Zend\Validator\File\ExcludeMimeType; /** * ExcludeMimeType testbed @@ -31,47 +32,47 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ class ExcludeMimeTypeTest extends \PHPUnit_Framework_TestCase { - /** - * Ensures that the validator follows expected behavior - * - * @return void - */ - public function testBasic() + public static function basicValues() { - $valuesExpected = array( - array('image/gif', false), + return array( + array('image/gif', true), array('image', false), array('test/notype', true), array('image/gif, image/jpeg', false), - array(array('image/vasa', 'image/gif'), false), - array(array('image/jpeg', 'gif'), false), - array(array('image/jpeg', 'jpeg'), true), + array(array('image/vasa', 'image/gif'), true), + array(array('image/gif', 'jpeg'), false), + array(array('image/gif', 'gif'), true), ); + } + /** + * Ensures that the validator follows expected behavior + * + * @group fml + * @dataProvider basicValues + */ + public function testBasic($input, $expected) + { $files = array( - 'name' => 'testsize.mo', - 'type' => 'image/gif', + 'name' => 'picture.jpg', + 'type' => 'image/jpeg', 'size' => 200, - 'tmp_name' => __DIR__ . '/_files/testsize.mo', + 'tmp_name' => __DIR__ . '/_files/picture.jpg', 'error' => 0 ); - foreach ($valuesExpected as $element) { - $validator = new File\ExcludeMimeType($element[0]); - $validator->enableHeaderCheck(); - $validator->isValid(__DIR__ . '/_files/testsize.mo', $files); - $this->assertEquals( - $element[1], - $validator->isValid(__DIR__ . '/_files/testsize.mo', $files), - "Tested with " . var_export($element, 1) - ); - } + $validator = new ExcludeMimeType($input); + $validator->enableHeaderCheck(); + $this->assertEquals( + $expected, + $validator->isValid(__DIR__ . '/_files/picture.jpg', $files) + ); } /** @@ -81,13 +82,13 @@ public function testBasic() */ public function testGetMimeType() { - $validator = new File\ExcludeMimeType('image/gif'); + $validator = new ExcludeMimeType('image/gif'); $this->assertEquals('image/gif', $validator->getMimeType()); - $validator = new File\ExcludeMimeType(array('image/gif', 'video', 'text/test')); + $validator = new ExcludeMimeType(array('image/gif', 'video', 'text/test')); $this->assertEquals('image/gif,video,text/test', $validator->getMimeType()); - $validator = new File\ExcludeMimeType(array('image/gif', 'video', 'text/test')); + $validator = new ExcludeMimeType(array('image/gif', 'video', 'text/test')); $this->assertEquals(array('image/gif', 'video', 'text/test'), $validator->getMimeType(true)); } @@ -98,7 +99,7 @@ public function testGetMimeType() */ public function testSetMimeType() { - $validator = new File\ExcludeMimeType('image/gif'); + $validator = new ExcludeMimeType('image/gif'); $validator->setMimeType('image/jpeg'); $this->assertEquals('image/jpeg', $validator->getMimeType()); $this->assertEquals(array('image/jpeg'), $validator->getMimeType(true)); @@ -119,7 +120,7 @@ public function testSetMimeType() */ public function testAddMimeType() { - $validator = new File\ExcludeMimeType('image/gif'); + $validator = new ExcludeMimeType('image/gif'); $validator->addMimeType('text'); $this->assertEquals('image/gif,text', $validator->getMimeType()); $this->assertEquals(array('image/gif', 'text'), $validator->getMimeType(true)); diff --git a/test/File/ExistsTest.php b/test/File/ExistsTest.php index 1cbe83737..1eb59f510 100644 --- a/test/File/ExistsTest.php +++ b/test/File/ExistsTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/ExtensionTest.php b/test/File/ExtensionTest.php index f02c68189..4de7ec12c 100644 --- a/test/File/ExtensionTest.php +++ b/test/File/ExtensionTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/FilesSizeTest.php b/test/File/FilesSizeTest.php index 093890152..65ec0eb3b 100644 --- a/test/File/FilesSizeTest.php +++ b/test/File/FilesSizeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/HashTest.php b/test/File/HashTest.php index 8ac1fde12..a5fc63cee 100644 --- a/test/File/HashTest.php +++ b/test/File/HashTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/ImageSizeTest.php b/test/File/ImageSizeTest.php index fffb5c6d5..687e34daf 100644 --- a/test/File/ImageSizeTest.php +++ b/test/File/ImageSizeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/IsCompressedTest.php b/test/File/IsCompressedTest.php index c4e42ade6..408d4ebcf 100644 --- a/test/File/IsCompressedTest.php +++ b/test/File/IsCompressedTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/IsImageTest.php b/test/File/IsImageTest.php index c0245efa7..ffa2d8d23 100644 --- a/test/File/IsImageTest.php +++ b/test/File/IsImageTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/Md5Test.php b/test/File/Md5Test.php index df06ac281..d7a7a5c64 100644 --- a/test/File/Md5Test.php +++ b/test/File/Md5Test.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/MimeTypeTest.php b/test/File/MimeTypeTest.php index ea301872d..afb5203b0 100644 --- a/test/File/MimeTypeTest.php +++ b/test/File/MimeTypeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -32,7 +32,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -153,7 +153,7 @@ public function testSetAndGetMagicFile() $this->assertEquals($magic, $mimetype); } - $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'can not be'); + $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'could not be'); $validator->setMagicFile('/unknown/magic/file'); } @@ -163,7 +163,7 @@ public function testSetMagicFileWithinConstructor() $this->markTestSkipped('This PHP Version has no finfo installed'); } - $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'The given magicfile is not accepted by finfo'); + $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'could not be used by ext/finfo'); $validator = new File\MimeType(array('image/gif', 'magicFile' => __FILE__)); } diff --git a/test/File/NotExistsTest.php b/test/File/NotExistsTest.php index 28ac1bea4..e4484600b 100644 --- a/test/File/NotExistsTest.php +++ b/test/File/NotExistsTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/Sha1Test.php b/test/File/Sha1Test.php index ce177933a..b8761d057 100644 --- a/test/File/Sha1Test.php +++ b/test/File/Sha1Test.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/SizeTest.php b/test/File/SizeTest.php index 607678550..d09e69d94 100644 --- a/test/File/SizeTest.php +++ b/test/File/SizeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/UploadTest.php b/test/File/UploadTest.php index e366707a2..5ba2fc731 100644 --- a/test/File/UploadTest.php +++ b/test/File/UploadTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/File/WordCountTest.php b/test/File/WordCountTest.php index 338321553..a247a72e1 100644 --- a/test/File/WordCountTest.php +++ b/test/File/WordCountTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator_File * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/FloatTest.php b/test/FloatTest.php index 59d84ebeb..f5a4e93eb 100644 --- a/test/FloatTest.php +++ b/test/FloatTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -37,7 +38,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -223,4 +224,40 @@ public function testPhpLocaleEnStringType() $this->assertFalse($valid->isValid('1000,3')); $this->assertFalse($valid->isValid('1.000,3')); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/GreaterThanTest.php b/test/GreaterThanTest.php index cf8e3a811..a35e374e3 100644 --- a/test/GreaterThanTest.php +++ b/test/GreaterThanTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -108,4 +109,40 @@ public function testGetInclusive() $validator = new Validator\GreaterThan(10); $this->assertEquals(false, $validator->getInclusive()); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\GreaterThan(1); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\GreaterThan(1); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/HexTest.php b/test/HexTest.php index ebfce5c55..01c04aa55 100644 --- a/test/HexTest.php +++ b/test/HexTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,6 +24,8 @@ */ namespace ZendTest\Validator; +use ReflectionClass; + /** * Test helper */ @@ -37,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -100,4 +102,40 @@ public function testNonStringValidation() { $this->assertFalse($this->_validator->isValid(array(1 => 1))); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/HostnameTest.php b/test/HostnameTest.php index 9ba5355f8..fb2e39989 100644 --- a/test/HostnameTest.php +++ b/test/HostnameTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,13 +23,14 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator\Hostname; +use Zend\Validator\Hostname, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -462,4 +463,40 @@ public function testIDNSI() $this->assertTrue($validator->isValid('tàrø.si')); $this->assertFalse($validator->isValid('رات.si')); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/IbanTest.php b/test/IbanTest.php index 360499f73..af13a4938 100644 --- a/test/IbanTest.php +++ b/test/IbanTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,18 +23,26 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; + +use ReflectionClass, + Zend\Registry, + Zend\Validator; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ class IbanTest extends \PHPUnit_Framework_TestCase { + public function setUp() + { + Registry::_unsetInstance(); + } + /** * Ensures that the validator follows expected behavior * @@ -87,4 +95,40 @@ public function testIbanDetectionWithoutLocale() $validator = new Validator\Iban(false); $this->assertTrue($validator->isValid('AT611904300234573201')); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\Iban(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Iban(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/IdenticalTest.php b/test/IdenticalTest.php index 6c73934fa..8b4507051 100644 --- a/test/IdenticalTest.php +++ b/test/IdenticalTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** Zend_Validator_Identical */ @@ -34,7 +35,7 @@ * @package Zend * @subpackage UnitTests * @uses Zend_Validator_Identical - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -132,4 +133,40 @@ public function testValidatingNonStrictToken() $validator->setStrict(true); $this->assertFalse($validator->isValid(array('token' => '123'))); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\Identical(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Identical(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/InArrayTest.php b/test/InArrayTest.php index 1a470d1b5..4d8bf91d1 100644 --- a/test/InArrayTest.php +++ b/test/InArrayTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -203,4 +204,40 @@ public function testRecursiveStandalone() $validator->setRecursive(true); $this->assertTrue($validator->isValid('A')); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\InArray(array()); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\InArray(array()); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/IntTest.php b/test/IntTest.php index 34c3cfdc2..829c50c70 100644 --- a/test/IntTest.php +++ b/test/IntTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,8 +23,9 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; -use Zend\Locale; +use Zend\Validator, + Zend\Locale, + ReflectionClass; /** * Test helper @@ -39,7 +40,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -138,4 +139,40 @@ public function testLocaleDetectsNoEnglishLocaleOnOtherSetLocale() $this->assertTrue($valid->isValid(1200)); $this->assertFalse($valid->isValid('1,200')); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/IpTest.php b/test/IpTest.php index dbf3f7377..595faf4ae 100644 --- a/test/IpTest.php +++ b/test/IpTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -24,6 +24,9 @@ */ namespace ZendTest\Validator; +use Zend\Validator, + ReflectionClass; + /** * Test helper */ @@ -36,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -260,4 +263,40 @@ public function testIPv4addressnotations() } } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/IsbnTest.php b/test/IsbnTest.php index 666378a78..755c7720f 100644 --- a/test/IsbnTest.php +++ b/test/IsbnTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -22,7 +22,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** @@ -30,7 +31,7 @@ * @package Zend_Validator * @subpackage UnitTests * @group Zend_Validator - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class IsbnTest extends \PHPUnit_Framework_TestCase @@ -233,4 +234,40 @@ public function testInvalidTypeGiven() $this->assertFalse($validator->isValid((float) 1.2345)); $this->assertFalse($validator->isValid((object) 'Test')); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\Isbn(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Isbn(); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/LessThanTest.php b/test/LessThanTest.php index 9eaa5f399..26dabffe7 100644 --- a/test/LessThanTest.php +++ b/test/LessThanTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -108,4 +109,40 @@ public function testGetInclusive() $validator = new Validator\LessThan(10); $this->assertEquals(false, $validator->getInclusive()); } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\LessThan(10); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\LessThan(10); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/MessageTest.php b/test/MessageTest.php index b35c91c1c..85d568133 100644 --- a/test/MessageTest.php +++ b/test/MessageTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,13 +23,14 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -266,5 +267,41 @@ public function testGetMessageVariables() $messages = $this->_validator->getMessages(); $this->assertEquals('variables: %notvar% 4 8 ', current($messages)); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/NotEmptyTest.php b/test/NotEmptyTest.php index 945b8f0e3..05b7a81b0 100644 --- a/test/NotEmptyTest.php +++ b/test/NotEmptyTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,13 +23,14 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -603,6 +604,42 @@ public function testArrayConfigNotationWithoutKey() $this->assertTrue($filter->isValid(array('xxx'))); $this->assertTrue($filter->isValid(null)); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } class ClassTest1 {} diff --git a/test/PostCodeTest.php b/test/PostCodeTest.php index a8fa56c40..972501bcc 100644 --- a/test/PostCodeTest.php +++ b/test/PostCodeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * @see Zend_Validator_PostCode @@ -33,7 +34,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -199,4 +200,40 @@ public function testServiceClass() $message = $this->_validator->getMessages(); $this->assertContains('not appear to be a postal code', $message['postcodeService']); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/RegexTest.php b/test/RegexTest.php index 507da5715..21a6f5293 100644 --- a/test/RegexTest.php +++ b/test/RegexTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -38,7 +39,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -98,7 +99,7 @@ public function testGetPattern() */ public function testBadPattern() { - $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'Internal error while'); + $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'Internal error parsing'); $validator = new Validator\Regex('/'); } @@ -133,4 +134,40 @@ public function testSpecialCharValidation() } } } + + public function testEqualsMessageTemplates() + { + $validator = new Validator\Regex('//'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = new Validator\Regex('//'); + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/Sitemap/ChangefreqTest.php b/test/Sitemap/ChangefreqTest.php index b0aaa11fb..d669fc162 100644 --- a/test/Sitemap/ChangefreqTest.php +++ b/test/Sitemap/ChangefreqTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/Sitemap/LastmodTest.php b/test/Sitemap/LastmodTest.php index 923fafa56..b642125c3 100644 --- a/test/Sitemap/LastmodTest.php +++ b/test/Sitemap/LastmodTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Translator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/Sitemap/LocTest.php b/test/Sitemap/LocTest.php index 2821c78f8..e42883fb9 100644 --- a/test/Sitemap/LocTest.php +++ b/test/Sitemap/LocTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Translator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/Sitemap/PriorityTest.php b/test/Sitemap/PriorityTest.php index c452d075d..9405a9486 100644 --- a/test/Sitemap/PriorityTest.php +++ b/test/Sitemap/PriorityTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Translator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/StaticValidatorTest.php b/test/StaticValidatorTest.php index be2da6ce4..bb5dfe853 100644 --- a/test/StaticValidatorTest.php +++ b/test/StaticValidatorTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ diff --git a/test/StringLengthTest.php b/test/StringLengthTest.php index 72e682522..87f99f36b 100644 --- a/test/StringLengthTest.php +++ b/test/StringLengthTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,7 +23,8 @@ * @namespace */ namespace ZendTest\Validator; -use Zend\Validator; +use Zend\Validator, + ReflectionClass; /** * Test helper @@ -37,7 +38,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */ @@ -173,4 +174,40 @@ public function testNonStringValidation() { $this->assertFalse($this->_validator->isValid(array(1 => 1))); } + + public function testEqualsMessageTemplates() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageTemplates')) { + return; + } + + $property = $reflection->getProperty('_messageTemplates'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageTemplates') + ); + } + + public function testEqualsMessageVariables() + { + $validator = $this->_validator; + $reflection = new ReflectionClass($validator); + + if(!$reflection->hasProperty('_messageVariables')) { + return; + } + + $property = $reflection->getProperty('_messageVariables'); + $property->setAccessible(true); + + $this->assertEquals( + $property->getValue($validator), + $validator->getOption('messageVariables') + ); + } } diff --git a/test/ValidateTest.php b/test/ValidateTest.php index f5f030349..43399000b 100644 --- a/test/ValidateTest.php +++ b/test/ValidateTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Validator * @subpackage UnitTests - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Validator */