From b8c76e3054d772beb332c3faa0747cb237633e81 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 8 Jun 2015 11:47:14 -0300 Subject: [PATCH] Fix some coding standards --- library/ExceptionIterator.php | 1 + .../Exceptions/AbstractGroupedException.php | 1 + .../Exceptions/AbstractNestedException.php | 3 +- library/Exceptions/AgeException.php | 1 + library/Exceptions/AllOfException.php | 1 + library/Exceptions/AlnumException.php | 1 + library/Exceptions/AlphaException.php | 1 + library/Exceptions/AlwaysInvalidException.php | 5 +- library/Exceptions/AlwaysValidException.php | 1 + library/Exceptions/ArrException.php | 1 + library/Exceptions/AtLeastException.php | 1 + library/Exceptions/AttributeException.php | 1 + library/Exceptions/BankAccountException.php | 3 +- library/Exceptions/BankException.php | 3 +- library/Exceptions/BaseException.php | 1 + library/Exceptions/BetweenException.php | 1 + library/Exceptions/BicException.php | 3 +- library/Exceptions/BoolException.php | 1 + library/Exceptions/CallException.php | 1 + library/Exceptions/CallbackException.php | 1 + library/Exceptions/CharsetException.php | 1 + library/Exceptions/CnhException.php | 1 + library/Exceptions/CntrlException.php | 1 + library/Exceptions/ComponentException.php | 1 + library/Exceptions/ConsonantException.php | 1 + library/Exceptions/ContainsException.php | 1 + library/Exceptions/CountryCodeException.php | 1 + library/Exceptions/CpfException.php | 1 + library/Exceptions/CreditCardException.php | 1 + library/Exceptions/DateException.php | 1 + library/Exceptions/DigitException.php | 1 + library/Exceptions/DirectoryException.php | 1 + library/Exceptions/DomainException.php | 1 + library/Exceptions/EachException.php | 1 + library/Exceptions/EmailException.php | 1 + library/Exceptions/EndsWithException.php | 1 + library/Exceptions/EqualsException.php | 1 + library/Exceptions/EvenException.php | 1 + library/Exceptions/ExceptionInterface.php | 1 + library/Exceptions/FalseException.php | 1 + library/Exceptions/FilterVarException.php | 1 + library/Exceptions/FloatException.php | 1 + library/Exceptions/GraphException.php | 1 + library/Exceptions/HexRgbColorException.php | 1 + library/Exceptions/HexaException.php | 1 + library/Exceptions/InException.php | 1 + library/Exceptions/InstanceException.php | 1 + library/Exceptions/IntException.php | 1 + library/Exceptions/IpException.php | 1 + library/Exceptions/JsonException.php | 1 + library/Exceptions/KeyException.php | 1 + library/Exceptions/LeapDateException.php | 1 + library/Exceptions/LeapYearException.php | 1 + library/Exceptions/LengthException.php | 1 + .../Locale/GermanBankAccountException.php | 3 +- .../Exceptions/Locale/GermanBankException.php | 3 +- .../Exceptions/Locale/GermanBicException.php | 3 +- library/Exceptions/LowercaseException.php | 1 + library/Exceptions/MacAddressException.php | 1 + library/Exceptions/MaxException.php | 1 + library/Exceptions/MinException.php | 1 + library/Exceptions/MinimumAgeException.php | 1 + library/Exceptions/MostOfException.php | 1 + library/Exceptions/MultipleException.php | 1 + library/Exceptions/NegativeException.php | 1 + .../NestedValidationExceptionInterface.php | 1 + library/Exceptions/NfeAccessKeyException.php | 1 + library/Exceptions/NoException.php | 1 + library/Exceptions/NoWhitespaceException.php | 1 + library/Exceptions/NoneOfException.php | 1 + library/Exceptions/NotEmptyException.php | 3 +- library/Exceptions/NotException.php | 1 + library/Exceptions/NullValueException.php | 1 + library/Exceptions/NumericException.php | 1 + library/Exceptions/ObjectException.php | 1 + library/Exceptions/OddException.php | 1 + library/Exceptions/OneOfException.php | 1 + library/Exceptions/PerfectSquareException.php | 1 + library/Exceptions/PhoneException.php | 1 + library/Exceptions/PositiveException.php | 1 + library/Exceptions/PostalCodeException.php | 1 + library/Exceptions/PrimeNumberException.php | 1 + library/Exceptions/PrntException.php | 1 + library/Exceptions/PunctException.php | 1 + library/Exceptions/RegexException.php | 1 + library/Exceptions/RomanException.php | 1 + library/Exceptions/SfException.php | 1 + library/Exceptions/SlugException.php | 1 + library/Exceptions/SpaceException.php | 1 + library/Exceptions/StartsWithException.php | 1 + library/Exceptions/StringException.php | 1 + library/Exceptions/TldException.php | 1 + library/Exceptions/TrueException.php | 1 + library/Exceptions/TypeException.php | 1 + library/Exceptions/UppercaseException.php | 1 + library/Exceptions/UrlException.php | 1 + library/Exceptions/ValidationException.php | 3 +- .../ValidationExceptionInterface.php | 1 + library/Exceptions/VersionException.php | 1 + library/Exceptions/VowelException.php | 1 + library/Exceptions/WhenException.php | 1 + library/Exceptions/XdigitException.php | 1 + library/Exceptions/YesException.php | 1 + library/Exceptions/ZendException.php | 1 + library/Factory.php | 4 +- library/Rules/AbstractComposite.php | 3 +- library/Rules/AbstractCountryInfo.php | 1 + library/Rules/AbstractCtypeRule.php | 1 + library/Rules/AbstractFilterRule.php | 3 +- library/Rules/AbstractInterval.php | 3 +- library/Rules/AbstractRegexRule.php | 1 + library/Rules/AbstractRelated.php | 1 + library/Rules/AbstractRule.php | 1 + library/Rules/AbstractSearcher.php | 1 + library/Rules/AbstractWrapper.php | 1 + library/Rules/Age.php | 1 + library/Rules/AllOf.php | 1 + library/Rules/Alnum.php | 1 + library/Rules/Alpha.php | 1 + library/Rules/AlwaysInvalid.php | 1 + library/Rules/AlwaysValid.php | 1 + library/Rules/Arr.php | 1 + library/Rules/Attribute.php | 1 + library/Rules/Bank.php | 1 + library/Rules/BankAccount.php | 1 + library/Rules/Base.php | 1 + library/Rules/Between.php | 1 + library/Rules/Bic.php | 1 + library/Rules/Bool.php | 1 + library/Rules/Call.php | 1 + library/Rules/Callback.php | 3 +- library/Rules/Charset.php | 1 + library/Rules/Cnh.php | 1 + library/Rules/Cnpj.php | 1 + library/Rules/Cntrl.php | 1 + library/Rules/Consonant.php | 1 + library/Rules/Consonants.php | 3 +- library/Rules/Contains.php | 1 + library/Rules/CountryCode.php | 1 + library/Rules/Cpf.php | 1 + library/Rules/CreditCard.php | 1 + library/Rules/Date.php | 5 +- library/Rules/Digit.php | 1 + library/Rules/Digits.php | 3 +- library/Rules/Directory.php | 1 + library/Rules/Domain.php | 3 +- library/Rules/Each.php | 1 + library/Rules/Email.php | 1 + library/Rules/EndsWith.php | 1 + library/Rules/Equals.php | 1 + library/Rules/Even.php | 1 + library/Rules/False.php | 5 +- library/Rules/FilterVar.php | 9 +- library/Rules/Float.php | 1 + library/Rules/Graph.php | 1 + library/Rules/HexRgbColor.php | 3 +- library/Rules/Hexa.php | 3 +- library/Rules/In.php | 3 +- library/Rules/Instance.php | 1 + library/Rules/Int.php | 1 + library/Rules/Ip.php | 1 + library/Rules/Json.php | 1 + library/Rules/Key.php | 1 + library/Rules/LeapDate.php | 1 + library/Rules/LeapYear.php | 1 + library/Rules/Length.php | 1 + library/Rules/Locale/Factory.php | 1 + library/Rules/Locale/GermanBank.php | 4 +- library/Rules/Locale/GermanBankAccount.php | 6 +- library/Rules/Locale/GermanBic.php | 4 +- library/Rules/Lowercase.php | 1 + library/Rules/MacAddress.php | 1 + library/Rules/Max.php | 1 + library/Rules/Min.php | 1 + library/Rules/MinimumAge.php | 1 + library/Rules/Multiple.php | 1 + library/Rules/Negative.php | 1 + library/Rules/NfeAccessKey.php | 6 +- library/Rules/No.php | 1 + library/Rules/NoWhitespace.php | 1 + library/Rules/NoneOf.php | 1 + library/Rules/Not.php | 1 + library/Rules/NotEmpty.php | 1 + library/Rules/NullValue.php | 1 + library/Rules/Numeric.php | 1 + library/Rules/Object.php | 1 + library/Rules/Odd.php | 1 + library/Rules/OneOf.php | 1 + library/Rules/PerfectSquare.php | 1 + library/Rules/Phone.php | 1 + library/Rules/Positive.php | 1 + library/Rules/PostalCode.php | 304 +++++++++--------- library/Rules/PrimeNumber.php | 3 +- library/Rules/Prnt.php | 1 + library/Rules/Punct.php | 1 + library/Rules/Regex.php | 1 + library/Rules/Roman.php | 1 + library/Rules/Sf.php | 1 + library/Rules/Slug.php | 1 + library/Rules/Space.php | 1 + library/Rules/StartsWith.php | 1 + library/Rules/String.php | 1 + library/Rules/Tld.php | 1 + library/Rules/True.php | 5 +- library/Rules/Type.php | 25 +- library/Rules/Uppercase.php | 1 + library/Rules/Url.php | 2 +- library/Rules/Version.php | 1 + library/Rules/Vowel.php | 1 + library/Rules/Vowels.php | 3 +- library/Rules/When.php | 1 + library/Rules/Xdigit.php | 1 + library/Rules/Yes.php | 1 + library/Rules/Zend.php | 1 + library/Validatable.php | 1 + library/Validator.php | 11 +- .../AbstractGroupedExceptionTest.php | 8 +- .../AbstractNestedExceptionTest.php | 21 +- tests/Exceptions/CheckExceptionsTest.php | 11 +- tests/Exceptions/ValidationExceptionTest.php | 17 +- tests/Rules/AbstractCompositeTest.php | 1 + tests/Rules/AbstractWrapperTest.php | 1 + tests/Rules/AgeTest.php | 1 + tests/Rules/AllOfTest.php | 22 +- tests/Rules/AlnumTest.php | 8 +- tests/Rules/AlphaTest.php | 8 +- tests/Rules/AlwaysInvalidTest.php | 11 +- tests/Rules/ArrTest.php | 13 +- tests/Rules/AttributeTest.php | 28 +- tests/Rules/BankAccountTest.php | 17 +- tests/Rules/BankTest.php | 13 +- tests/Rules/BaseTest.php | 11 +- tests/Rules/BetweenTest.php | 8 +- tests/Rules/BicTest.php | 13 +- tests/Rules/BoolTest.php | 2 +- tests/Rules/CallTest.php | 14 +- tests/Rules/CallbackTest.php | 11 +- tests/Rules/CharsetTest.php | 8 +- tests/Rules/CnhTest.php | 4 +- tests/Rules/CnpjTest.php | 8 +- tests/Rules/CntrlTest.php | 10 +- tests/Rules/ConsonantTest.php | 10 +- tests/Rules/ContainsTest.php | 4 +- tests/Rules/CpfTest.php | 10 +- tests/Rules/CreditCardTest.php | 5 +- tests/Rules/DateTest.php | 23 +- tests/Rules/DigitTest.php | 10 +- tests/Rules/DirectoryTest.php | 18 +- tests/Rules/DomainTest.php | 13 +- tests/Rules/EachTest.php | 2 +- tests/Rules/EmailTest.php | 6 +- tests/Rules/EndsWithTest.php | 4 +- tests/Rules/EqualsTest.php | 8 +- tests/Rules/EvenTest.php | 4 +- tests/Rules/ExistsTest.php | 4 +- tests/Rules/FalseTest.php | 1 + tests/Rules/FileTest.php | 4 +- tests/Rules/FilterVarTest.php | 1 + tests/Rules/FloatTest.php | 4 +- tests/Rules/GraphTest.php | 10 +- tests/Rules/HexRgbColorTest.php | 2 +- tests/Rules/HexaTest.php | 4 +- tests/Rules/InTest.php | 7 +- tests/Rules/InstanceTest.php | 12 +- tests/Rules/IntTest.php | 5 +- tests/Rules/IpTest.php | 7 +- tests/Rules/JsonTest.php | 9 +- tests/Rules/KeyTest.php | 12 +- tests/Rules/LeapDateTest.php | 2 +- tests/Rules/LeapYearTest.php | 4 +- tests/Rules/LengthTest.php | 10 +- tests/Rules/Locale/FactoryTest.php | 1 + tests/Rules/Locale/GermanBankAccountTest.php | 27 +- tests/Rules/Locale/GermanBankTest.php | 21 +- tests/Rules/Locale/GermanBicTest.php | 21 +- tests/Rules/LowercaseTest.php | 2 +- tests/Rules/MacAddressTest.php | 5 +- tests/Rules/MaxTest.php | 2 +- tests/Rules/MinTest.php | 3 +- tests/Rules/MininumAgeTest.php | 8 +- tests/Rules/MultipleTest.php | 3 +- tests/Rules/NegativeTest.php | 5 +- tests/Rules/NfeAccessKeyTest.php | 9 +- tests/Rules/NoTest.php | 1 + tests/Rules/NoWhitespaceTest.php | 3 +- tests/Rules/NoneOfTest.php | 14 +- tests/Rules/NotEmptyTest.php | 8 +- tests/Rules/NotTest.php | 9 +- tests/Rules/NullValueTest.php | 5 +- tests/Rules/NumericTest.php | 5 +- tests/Rules/ObjectTest.php | 9 +- tests/Rules/OddTest.php | 5 +- tests/Rules/OneOfTest.php | 32 +- tests/Rules/PerfectSquareTest.php | 6 +- tests/Rules/PhoneTest.php | 5 +- tests/Rules/PositiveTest.php | 5 +- tests/Rules/PostalCodeTest.php | 1 + tests/Rules/PrimeNumberTest.php | 6 +- tests/Rules/PrntTest.php | 14 +- tests/Rules/PunctTest.php | 10 +- tests/Rules/ReadableTest.php | 4 +- tests/Rules/RegexTest.php | 2 +- tests/Rules/RomanTest.php | 5 +- tests/Rules/SfTest.php | 1 + tests/Rules/SlugTest.php | 8 +- tests/Rules/SpaceTest.php | 16 +- tests/Rules/StartsWithTest.php | 5 +- tests/Rules/StringTest.php | 9 +- tests/Rules/SymbolicLinkTest.php | 4 +- tests/Rules/TrueTest.php | 1 + tests/Rules/TypeTest.php | 7 +- tests/Rules/UploadedTest.php | 6 +- tests/Rules/UppercaseTest.php | 2 +- tests/Rules/UrlTest.php | 1 + tests/Rules/VersionTest.php | 2 +- tests/Rules/VowelTest.php | 10 +- tests/Rules/WhenTest.php | 20 +- tests/Rules/WritableTest.php | 4 +- tests/Rules/XdigitTest.php | 4 +- tests/Rules/YesTest.php | 1 + tests/Rules/ZendTest.php | 36 +-- tests/ValidatorTest.php | 13 +- tests/library/LocaleTestCase.php | 1 + 323 files changed, 860 insertions(+), 670 deletions(-) diff --git a/library/ExceptionIterator.php b/library/ExceptionIterator.php index eb08e861..23ce6028 100644 --- a/library/ExceptionIterator.php +++ b/library/ExceptionIterator.php @@ -1,4 +1,5 @@ related) - && current($this->related) instanceof AbstractNestedException) { + && current($this->related) instanceof self) { return current($this->related)->getRelated(); } else { return $this->related; diff --git a/library/Exceptions/AgeException.php b/library/Exceptions/AgeException.php index 675683dc..76286b3f 100644 --- a/library/Exceptions/AgeException.php +++ b/library/Exceptions/AgeException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} is always invalid', - self::SIMPLE => '{{name}} is not valid', + self::SIMPLE => '{{name}} is not valid', ), self::MODE_NEGATIVE => array( self::STANDARD => '{{name}} is always valid', - self::SIMPLE => '{{name}} is valid', + self::SIMPLE => '{{name}} is valid', ), ); } diff --git a/library/Exceptions/AlwaysValidException.php b/library/Exceptions/AlwaysValidException.php index 674fe291..f241d5f7 100644 --- a/library/Exceptions/AlwaysValidException.php +++ b/library/Exceptions/AlwaysValidException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a bank account', - ) + ), ); } diff --git a/library/Exceptions/BankException.php b/library/Exceptions/BankException.php index 187090d1..f893db0c 100644 --- a/library/Exceptions/BankException.php +++ b/library/Exceptions/BankException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a bank', - ) + ), ); } diff --git a/library/Exceptions/BaseException.php b/library/Exceptions/BaseException.php index cf7c00e0..6d4664c3 100644 --- a/library/Exceptions/BaseException.php +++ b/library/Exceptions/BaseException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a BIC', - ) + ), ); } diff --git a/library/Exceptions/BoolException.php b/library/Exceptions/BoolException.php index 4529f0d0..4f19d0df 100644 --- a/library/Exceptions/BoolException.php +++ b/library/Exceptions/BoolException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a german bank account', - ) + ), ); } diff --git a/library/Exceptions/Locale/GermanBankException.php b/library/Exceptions/Locale/GermanBankException.php index 25279f49..6d19b09c 100644 --- a/library/Exceptions/Locale/GermanBankException.php +++ b/library/Exceptions/Locale/GermanBankException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a german bank', - ) + ), ); } diff --git a/library/Exceptions/Locale/GermanBicException.php b/library/Exceptions/Locale/GermanBicException.php index b978c380..d9ec730d 100644 --- a/library/Exceptions/Locale/GermanBicException.php +++ b/library/Exceptions/Locale/GermanBicException.php @@ -1,4 +1,5 @@ array( self::STANDARD => '{{name}} must not be a german BIC', - ) + ), ); } diff --git a/library/Exceptions/LowercaseException.php b/library/Exceptions/LowercaseException.php index f83db92f..5e89f722 100644 --- a/library/Exceptions/LowercaseException.php +++ b/library/Exceptions/LowercaseException.php @@ -1,4 +1,5 @@ getName() == "" ? static::STANDARD : static::NAMED; + return $this->getName() == '' ? static::STANDARD : static::NAMED; } } diff --git a/library/Exceptions/NotException.php b/library/Exceptions/NotException.php index 01ebcfb0..6e7e10f0 100644 --- a/library/Exceptions/NotException.php +++ b/library/Exceptions/NotException.php @@ -1,4 +1,5 @@ format('Y-m-d H:i:s'); } else { - return "Object of class ".get_class($value); + return 'Object of class '.get_class($value); } } diff --git a/library/Exceptions/ValidationExceptionInterface.php b/library/Exceptions/ValidationExceptionInterface.php index 093ee601..63db8f2d 100644 --- a/library/Exceptions/ValidationExceptionInterface.php +++ b/library/Exceptions/ValidationExceptionInterface.php @@ -1,4 +1,5 @@ getRulePrefixes() as $prefix) { $className = $prefix.ucfirst($ruleName); - if (! class_exists($className)) { + if (!class_exists($className)) { continue; } $reflection = new ReflectionClass($className); - if (! $reflection->isSubclassOf('Respect\\Validation\\Validatable')) { + if (!$reflection->isSubclassOf('Respect\\Validation\\Validatable')) { throw new ComponentException(sprintf('"%s" is not a valid respect rule', $className)); } diff --git a/library/Rules/AbstractComposite.php b/library/Rules/AbstractComposite.php index e9eed154..77c08b3d 100644 --- a/library/Rules/AbstractComposite.php +++ b/library/Rules/AbstractComposite.php @@ -1,4 +1,5 @@ getName() && $this->getName()) { + if (!$validator->getName() && $this->getName()) { $validator->setName($this->getName()); } diff --git a/library/Rules/AbstractCountryInfo.php b/library/Rules/AbstractCountryInfo.php index 847ca977..83ddfae6 100644 --- a/library/Rules/AbstractCountryInfo.php +++ b/library/Rules/AbstractCountryInfo.php @@ -1,4 +1,5 @@ interval = $interval; + $this->interval = $interval; $this->inclusive = $inclusive; } diff --git a/library/Rules/AbstractRegexRule.php b/library/Rules/AbstractRegexRule.php index 465e4202..b49933e7 100644 --- a/library/Rules/AbstractRegexRule.php +++ b/library/Rules/AbstractRegexRule.php @@ -1,4 +1,5 @@ 'Y-m-d\TH:i:sP', - 'r' => 'D, d M Y H:i:s O', + 'c' => 'Y-m-d\TH:i:sP', + 'r' => 'D, d M Y H:i:s O', ); if (in_array($this->format, array_keys($exceptionalFormats))) { diff --git a/library/Rules/Digit.php b/library/Rules/Digit.php index ec067114..c64c1802 100644 --- a/library/Rules/Digit.php +++ b/library/Rules/Digit.php @@ -1,4 +1,5 @@ isValidFilter($arguments[0])) { + if (!$this->isValidFilter($arguments[0])) { throw new ComponentException('Cannot accept the given filter'); } - $this->callback = 'filter_var'; + $this->callback = 'filter_var'; $this->arguments = $arguments; } @@ -31,7 +32,7 @@ class FilterVar extends Callback FILTER_VALIDATE_INT, FILTER_VALIDATE_IP, FILTER_VALIDATE_REGEXP, - FILTER_VALIDATE_URL + FILTER_VALIDATE_URL, ) ); } diff --git a/library/Rules/Float.php b/library/Rules/Float.php index d207b904..6c2ca174 100644 --- a/library/Rules/Float.php +++ b/library/Rules/Float.php @@ -1,4 +1,5 @@ haystack = $haystack; + $this->haystack = $haystack; $this->compareIdentical = $compareIdentical; } } diff --git a/library/Rules/Instance.php b/library/Rules/Instance.php index fb3229c1..3ac41db5 100644 --- a/library/Rules/Instance.php +++ b/library/Rules/Instance.php @@ -1,4 +1,5 @@ + * * @see BAV::isValidBank() */ class GermanBank extends AbstractRule @@ -31,7 +33,7 @@ class GermanBank extends AbstractRule } /** - * @return boolean + * @return bool */ public function validate($input) { diff --git a/library/Rules/Locale/GermanBankAccount.php b/library/Rules/Locale/GermanBankAccount.php index c3ad68a9..be4966f5 100644 --- a/library/Rules/Locale/GermanBankAccount.php +++ b/library/Rules/Locale/GermanBankAccount.php @@ -1,4 +1,5 @@ + * * @see BAV::isValidBankAccount() */ class GermanBankAccount extends AbstractRule @@ -32,12 +34,12 @@ class GermanBankAccount extends AbstractRule if (null === $bav) { $bav = new BAV(); } - $this->bav = $bav; + $this->bav = $bav; $this->bank = $bank; } /** - * @return boolean + * @return bool */ public function validate($input) { diff --git a/library/Rules/Locale/GermanBic.php b/library/Rules/Locale/GermanBic.php index 4d207838..057fd58d 100644 --- a/library/Rules/Locale/GermanBic.php +++ b/library/Rules/Locale/GermanBic.php @@ -1,4 +1,5 @@ + * * @see BAV::isValidBIC() * @see \malkusch\bav\Configuration * @see \malkusch\bav\ConfigurationRegistry::setConfiguration() @@ -38,7 +40,7 @@ class GermanBic extends AbstractRule } /** - * @return boolean + * @return bool */ public function validate($input) { diff --git a/library/Rules/Lowercase.php b/library/Rules/Lowercase.php index 8f48ad64..98c9826f 100644 --- a/library/Rules/Lowercase.php +++ b/library/Rules/Lowercase.php @@ -1,4 +1,5 @@ "/^(?:AD)*(\d{3})$/", - "AM" => "/^(\d{6})$/", - "AR" => "/^([A-Z]\d{4}[A-Z]{3})$/", - "AT" => "/^(\d{4})$/", - "AU" => "/^(\d{4})$/", - "AX" => "/^(?:FI)*(\d{5})$/", - "AZ" => "/^(?:AZ)*(\d{4})$/", - "BA" => "/^(\d{5})$/", - "BB" => "/^(?:BB)*(\d{5})$/", - "BD" => "/^(\d{4})$/", - "BE" => "/^(\d{4})$/", - "BG" => "/^(\d{4})$/", - "BH" => "/^(\d{3}\d?)$/", - "BM" => "/^([A-Z]{2}\d{2})$/", - "BN" => "/^([A-Z]{2}\d{4})$/", - "BR" => "/^(\d{8}|\d{5}-\d{3})$/", - "BY" => "/^(\d{6})$/", - "CA" => "/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/", - "CH" => "/^(\d{4})$/", - "CL" => "/^(\d{7})$/", - "CN" => "/^(\d{6})$/", - "CR" => "/^(\d{4})$/", - "CS" => "/^(\d{5})$/", - "CU" => "/^(?:CP)*(\d{5})$/", - "CV" => "/^(\d{4})$/", - "CX" => "/^(\d{4})$/", - "CY" => "/^(\d{4})$/", - "CZ" => "/^(\d{5})$/", - "DE" => "/^(\d{5})$/", - "DK" => "/^(\d{4})$/", - "DO" => "/^(\d{5})$/", - "DZ" => "/^(\d{5})$/", - "EC" => "/^([a-zA-Z]\d{4}[a-zA-Z])$/", - "EE" => "/^(\d{5})$/", - "EG" => "/^(\d{5})$/", - "ES" => "/^(\d{5})$/", - "ET" => "/^(\d{4})$/", - "FI" => "/^(?:FI)*(\d{5})$/", - "FM" => "/^(\d{5})$/", - "FO" => "/^(?:FO)*(\d{3})$/", - "FR" => "/^(\d{5})$/", - "GB" => "/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$/", - "GE" => "/^(\d{4})$/", - "GF" => "/^((97|98)3\d{2})$/", - "GG" => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - "GL" => "/^(\d{4})$/", - "GP" => "/^((97|98)\d{3})$/", - "GR" => "/^(\d{5})$/", - "GT" => "/^(\d{5})$/", - "GU" => "/^(969\d{2})$/", - "GW" => "/^(\d{4})$/", - "HN" => "/^([A-Z]{2}\d{4})$/", - "HR" => "/^(?:HR)*(\d{5})$/", - "HT" => "/^(?:HT)*(\d{4})$/", - "HU" => "/^(\d{4})$/", - "ID" => "/^(\d{5})$/", - "IL" => "/^(\d{5})$/", - "IM" => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - "IN" => "/^(\d{6})$/", - "IQ" => "/^(\d{5})$/", - "IR" => "/^(\d{10})$/", - "IS" => "/^(\d{3})$/", - "IT" => "/^(\d{5})$/", - "JE" => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - "JO" => "/^(\d{5})$/", - "JP" => "/^(\d{7})$/", - "KE" => "/^(\d{5})$/", - "KG" => "/^(\d{6})$/", - "KH" => "/^(\d{5})$/", - "KP" => "/^(\d{6})$/", - "KR" => "/^(?:SEOUL)*(\d{6})$/", - "KW" => "/^(\d{5})$/", - "KZ" => "/^(\d{6})$/", - "LA" => "/^(\d{5})$/", - "LB" => "/^(\d{4}(\d{4})?)$/", - "LI" => "/^(\d{4})$/", - "LK" => "/^(\d{5})$/", - "LR" => "/^(\d{4})$/", - "LS" => "/^(\d{3})$/", - "LT" => "/^(?:LT)*(\d{5})$/", - "LU" => "/^(\d{4})$/", - "LV" => "/^(?:LV)*(\d{4})$/", - "MA" => "/^(\d{5})$/", - "MC" => "/^(\d{5})$/", - "MD" => "/^(?:MD)*(\d{4})$/", - "ME" => "/^(\d{5})$/", - "MG" => "/^(\d{3})$/", - "MK" => "/^(\d{4})$/", - "MM" => "/^(\d{5})$/", - "MN" => "/^(\d{6})$/", - "MQ" => "/^(\d{5})$/", - "MT" => "/^([A-Z]{3}\d{2}\d?)$/", - "MV" => "/^(\d{5})$/", - "MX" => "/^(\d{5})$/", - "MY" => "/^(\d{5})$/", - "MZ" => "/^(\d{4})$/", - "NC" => "/^(\d{5})$/", - "NE" => "/^(\d{4})$/", - "NF" => "/^(\d{4})$/", - "NG" => "/^(\d{6})$/", - "NI" => "/^(\d{7})$/", - "NL" => "/^(\d{4}[A-Z]{2})$/", - "NO" => "/^(\d{4})$/", - "NP" => "/^(\d{5})$/", - "NZ" => "/^(\d{4})$/", - "OM" => "/^(\d{3})$/", - "PF" => "/^((97|98)7\d{2})$/", - "PG" => "/^(\d{3})$/", - "PH" => "/^(\d{4})$/", - "PK" => "/^(\d{5})$/", - "PL" => "/^(\d{5})$/", - "PM" => "/^(97500)$/", - "PR" => "/^(\d{9})$/", - "PT" => "/^(\d{7})$/", - "PW" => "/^(96940)$/", - "PY" => "/^(\d{4})$/", - "RE" => "/^((97|98)(4|7|8)\d{2})$/", - "RO" => "/^(\d{6})$/", - "RS" => "/^(\d{6})$/", - "RU" => "/^(\d{6})$/", - "SA" => "/^(\d{5})$/", - "SD" => "/^(\d{5})$/", - "SE" => "/^(?:SE)*(\d{5})$/", - "SG" => "/^(\d{6})$/", - "SH" => "/^(STHL1ZZ)$/", - "SI" => "/^(?:SI)*(\d{4})$/", - "SK" => "/^(\d{5})$/", - "SM" => "/^(4789\d)$/", - "SN" => "/^(\d{5})$/", - "SO" => "/^([A-Z]{2}\d{5})$/", - "SV" => "/^(?:CP)*(\d{4})$/", - "SZ" => "/^([A-Z]\d{3})$/", - "TC" => "/^(TKCA 1ZZ)$/", - "TH" => "/^(\d{5})$/", - "TJ" => "/^(\d{6})$/", - "TM" => "/^(\d{6})$/", - "TN" => "/^(\d{4})$/", - "TR" => "/^(\d{5})$/", - "TW" => "/^(\d{5})$/", - "UA" => "/^(\d{5})$/", - "US" => "/^\d{5}(-\d{4})?$/", - "UY" => "/^(\d{5})$/", - "UZ" => "/^(\d{6})$/", - "VA" => "/^(\d{5})$/", - "VE" => "/^(\d{4})$/", - "VI" => "/^\d{5}(-\d{4})?$/", - "VN" => "/^(\d{6})$/", - "WF" => "/^(986\d{2})$/", - "YT" => "/^(\d{5})$/", - "ZA" => "/^(\d{4})$/", - "ZM" => "/^(\d{5})$/", + 'AD' => "/^(?:AD)*(\d{3})$/", + 'AM' => "/^(\d{6})$/", + 'AR' => "/^([A-Z]\d{4}[A-Z]{3})$/", + 'AT' => "/^(\d{4})$/", + 'AU' => "/^(\d{4})$/", + 'AX' => "/^(?:FI)*(\d{5})$/", + 'AZ' => "/^(?:AZ)*(\d{4})$/", + 'BA' => "/^(\d{5})$/", + 'BB' => "/^(?:BB)*(\d{5})$/", + 'BD' => "/^(\d{4})$/", + 'BE' => "/^(\d{4})$/", + 'BG' => "/^(\d{4})$/", + 'BH' => "/^(\d{3}\d?)$/", + 'BM' => "/^([A-Z]{2}\d{2})$/", + 'BN' => "/^([A-Z]{2}\d{4})$/", + 'BR' => "/^(\d{8}|\d{5}-\d{3})$/", + 'BY' => "/^(\d{6})$/", + 'CA' => "/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/", + 'CH' => "/^(\d{4})$/", + 'CL' => "/^(\d{7})$/", + 'CN' => "/^(\d{6})$/", + 'CR' => "/^(\d{4})$/", + 'CS' => "/^(\d{5})$/", + 'CU' => "/^(?:CP)*(\d{5})$/", + 'CV' => "/^(\d{4})$/", + 'CX' => "/^(\d{4})$/", + 'CY' => "/^(\d{4})$/", + 'CZ' => "/^(\d{5})$/", + 'DE' => "/^(\d{5})$/", + 'DK' => "/^(\d{4})$/", + 'DO' => "/^(\d{5})$/", + 'DZ' => "/^(\d{5})$/", + 'EC' => "/^([a-zA-Z]\d{4}[a-zA-Z])$/", + 'EE' => "/^(\d{5})$/", + 'EG' => "/^(\d{5})$/", + 'ES' => "/^(\d{5})$/", + 'ET' => "/^(\d{4})$/", + 'FI' => "/^(?:FI)*(\d{5})$/", + 'FM' => "/^(\d{5})$/", + 'FO' => "/^(?:FO)*(\d{3})$/", + 'FR' => "/^(\d{5})$/", + 'GB' => '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$/', + 'GE' => "/^(\d{4})$/", + 'GF' => "/^((97|98)3\d{2})$/", + 'GG' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", + 'GL' => "/^(\d{4})$/", + 'GP' => "/^((97|98)\d{3})$/", + 'GR' => "/^(\d{5})$/", + 'GT' => "/^(\d{5})$/", + 'GU' => "/^(969\d{2})$/", + 'GW' => "/^(\d{4})$/", + 'HN' => "/^([A-Z]{2}\d{4})$/", + 'HR' => "/^(?:HR)*(\d{5})$/", + 'HT' => "/^(?:HT)*(\d{4})$/", + 'HU' => "/^(\d{4})$/", + 'ID' => "/^(\d{5})$/", + 'IL' => "/^(\d{5})$/", + 'IM' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", + 'IN' => "/^(\d{6})$/", + 'IQ' => "/^(\d{5})$/", + 'IR' => "/^(\d{10})$/", + 'IS' => "/^(\d{3})$/", + 'IT' => "/^(\d{5})$/", + 'JE' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", + 'JO' => "/^(\d{5})$/", + 'JP' => "/^(\d{7})$/", + 'KE' => "/^(\d{5})$/", + 'KG' => "/^(\d{6})$/", + 'KH' => "/^(\d{5})$/", + 'KP' => "/^(\d{6})$/", + 'KR' => "/^(?:SEOUL)*(\d{6})$/", + 'KW' => "/^(\d{5})$/", + 'KZ' => "/^(\d{6})$/", + 'LA' => "/^(\d{5})$/", + 'LB' => "/^(\d{4}(\d{4})?)$/", + 'LI' => "/^(\d{4})$/", + 'LK' => "/^(\d{5})$/", + 'LR' => "/^(\d{4})$/", + 'LS' => "/^(\d{3})$/", + 'LT' => "/^(?:LT)*(\d{5})$/", + 'LU' => "/^(\d{4})$/", + 'LV' => "/^(?:LV)*(\d{4})$/", + 'MA' => "/^(\d{5})$/", + 'MC' => "/^(\d{5})$/", + 'MD' => "/^(?:MD)*(\d{4})$/", + 'ME' => "/^(\d{5})$/", + 'MG' => "/^(\d{3})$/", + 'MK' => "/^(\d{4})$/", + 'MM' => "/^(\d{5})$/", + 'MN' => "/^(\d{6})$/", + 'MQ' => "/^(\d{5})$/", + 'MT' => "/^([A-Z]{3}\d{2}\d?)$/", + 'MV' => "/^(\d{5})$/", + 'MX' => "/^(\d{5})$/", + 'MY' => "/^(\d{5})$/", + 'MZ' => "/^(\d{4})$/", + 'NC' => "/^(\d{5})$/", + 'NE' => "/^(\d{4})$/", + 'NF' => "/^(\d{4})$/", + 'NG' => "/^(\d{6})$/", + 'NI' => "/^(\d{7})$/", + 'NL' => "/^(\d{4}[A-Z]{2})$/", + 'NO' => "/^(\d{4})$/", + 'NP' => "/^(\d{5})$/", + 'NZ' => "/^(\d{4})$/", + 'OM' => "/^(\d{3})$/", + 'PF' => "/^((97|98)7\d{2})$/", + 'PG' => "/^(\d{3})$/", + 'PH' => "/^(\d{4})$/", + 'PK' => "/^(\d{5})$/", + 'PL' => "/^(\d{5})$/", + 'PM' => '/^(97500)$/', + 'PR' => "/^(\d{9})$/", + 'PT' => "/^(\d{7})$/", + 'PW' => '/^(96940)$/', + 'PY' => "/^(\d{4})$/", + 'RE' => "/^((97|98)(4|7|8)\d{2})$/", + 'RO' => "/^(\d{6})$/", + 'RS' => "/^(\d{6})$/", + 'RU' => "/^(\d{6})$/", + 'SA' => "/^(\d{5})$/", + 'SD' => "/^(\d{5})$/", + 'SE' => "/^(?:SE)*(\d{5})$/", + 'SG' => "/^(\d{6})$/", + 'SH' => '/^(STHL1ZZ)$/', + 'SI' => "/^(?:SI)*(\d{4})$/", + 'SK' => "/^(\d{5})$/", + 'SM' => "/^(4789\d)$/", + 'SN' => "/^(\d{5})$/", + 'SO' => "/^([A-Z]{2}\d{5})$/", + 'SV' => "/^(?:CP)*(\d{4})$/", + 'SZ' => "/^([A-Z]\d{3})$/", + 'TC' => '/^(TKCA 1ZZ)$/', + 'TH' => "/^(\d{5})$/", + 'TJ' => "/^(\d{6})$/", + 'TM' => "/^(\d{6})$/", + 'TN' => "/^(\d{4})$/", + 'TR' => "/^(\d{5})$/", + 'TW' => "/^(\d{5})$/", + 'UA' => "/^(\d{5})$/", + 'US' => "/^\d{5}(-\d{4})?$/", + 'UY' => "/^(\d{5})$/", + 'UZ' => "/^(\d{6})$/", + 'VA' => "/^(\d{5})$/", + 'VE' => "/^(\d{4})$/", + 'VI' => "/^\d{5}(-\d{4})?$/", + 'VN' => "/^(\d{6})$/", + 'WF' => "/^(986\d{2})$/", + 'YT' => "/^(\d{5})$/", + 'ZA' => "/^(\d{4})$/", + 'ZM' => "/^(\d{5})$/", ); public function __construct($countryCode, CountryCode $countryCodeRule = null) { $countryCodeRule = $countryCodeRule ?: new CountryCode(); - if (! $countryCodeRule->validate($countryCode)) { + if (!$countryCodeRule->validate($countryCode)) { throw new ComponentException(sprintf('Cannot validate postal code from "%s" country', $countryCode)); } diff --git a/library/Rules/PrimeNumber.php b/library/Rules/PrimeNumber.php index ad148eac..b7f046e1 100644 --- a/library/Rules/PrimeNumber.php +++ b/library/Rules/PrimeNumber.php @@ -1,4 +1,5 @@ 'array', - 'bool' => 'boolean', - 'boolean' => 'boolean', - 'callable' => 'callable', - 'double' => 'double', - 'float' => 'double', - 'int' => 'integer', - 'integer' => 'integer', - 'null' => 'NULL', - 'object' => 'object', - 'resource' => 'resource', - 'string' => 'string', + 'array' => 'array', + 'bool' => 'boolean', + 'boolean' => 'boolean', + 'callable' => 'callable', + 'double' => 'double', + 'float' => 'double', + 'int' => 'integer', + 'integer' => 'integer', + 'null' => 'NULL', + 'object' => 'object', + 'resource' => 'resource', + 'string' => 'string', ); public function __construct($type) diff --git a/library/Rules/Uppercase.php b/library/Rules/Uppercase.php index e86343f9..720a770f 100644 --- a/library/Rules/Uppercase.php +++ b/library/Rules/Uppercase.php @@ -1,4 +1,5 @@ addRule(static::buildRule($method, $arguments)); } - /** * @param mixed $input * @param array $extraParams @@ -219,7 +214,7 @@ class Validator extends AllOf } /** - * Create instance validator + * Create instance validator. * * @return Validator */ diff --git a/tests/Exceptions/AbstractGroupedExceptionTest.php b/tests/Exceptions/AbstractGroupedExceptionTest.php index d2ca8460..84288ffe 100644 --- a/tests/Exceptions/AbstractGroupedExceptionTest.php +++ b/tests/Exceptions/AbstractGroupedExceptionTest.php @@ -1,17 +1,17 @@ addRelated($e2); $e2->addRelated($int); $result = $e->getRelated(); $this->assertSame($int, current($result)); } } - diff --git a/tests/Exceptions/AbstractNestedExceptionTest.php b/tests/Exceptions/AbstractNestedExceptionTest.php index fd0f0b1a..9b4dfe70 100644 --- a/tests/Exceptions/AbstractNestedExceptionTest.php +++ b/tests/Exceptions/AbstractNestedExceptionTest.php @@ -1,11 +1,10 @@ addRelated($node); $this->assertEquals(1, count($composite->getRelated(true))); $this->assertContainsOnly($node, $composite->getRelated()); @@ -33,8 +32,8 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase public function testAddingTheSameInstanceShouldAddJustASingleReference() { - $composite = new AttributeException; - $node = new IntException; + $composite = new AttributeException(); + $node = new IntException(); $composite->addRelated($node); $composite->addRelated($node); $composite->addRelated($node); @@ -44,10 +43,10 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase public function testFindRelatedShouldFindCompositeExceptions() { - $foo = new AttributeException; - $bar = new AttributeException; - $baz = new AttributeException; - $bat = new AttributeException; + $foo = new AttributeException(); + $bar = new AttributeException(); + $baz = new AttributeException(); + $bat = new AttributeException(); $foo->configure('foo'); $bar->configure('bar'); $baz->configure('baz'); @@ -135,7 +134,7 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase $messages = $e->findMessages( array( 'allOf' => 'Invalid {{name}}', - 'first_name.length' => 'Invalid length for {{name}} {{input}}' + 'first_name.length' => 'Invalid length for {{name}} {{input}}', ) ); $this->assertEquals($messages['allOf'], 'Invalid Validation Form'); diff --git a/tests/Exceptions/CheckExceptionsTest.php b/tests/Exceptions/CheckExceptionsTest.php index b6ec14c4..c629e6fe 100644 --- a/tests/Exceptions/CheckExceptionsTest.php +++ b/tests/Exceptions/CheckExceptionsTest.php @@ -32,7 +32,7 @@ class CheckExceptionsTest extends \PHPUnit_Framework_TestCase $reflectionClass = new ReflectionClass($className); if ($reflectionClass->isAbstract() || $reflectionClass->isInterface() - || ! $reflectionClass->implementsInterface('Respect\\Validation\\Validatable')) { + || !$reflectionClass->implementsInterface('Respect\\Validation\\Validatable')) { continue; } @@ -55,7 +55,7 @@ class CheckExceptionsTest extends \PHPUnit_Framework_TestCase $missingExceptions[] = $ruleName; } - $this->assertEmpty($missingExceptions, 'No exceptions for: ' . $this->formatArrayAsString($missingExceptions)); + $this->assertEmpty($missingExceptions, 'No exceptions for: '.$this->formatArrayAsString($missingExceptions)); } public function testEveryRuleExceptionImplementsValidationExceptionInterface() @@ -73,22 +73,25 @@ class CheckExceptionsTest extends \PHPUnit_Framework_TestCase } $this->assertEmpty($exceptionsNotImplementingInterface, - 'ValidationExceptionInterface not implemented in: ' . + 'ValidationExceptionInterface not implemented in: '. $this->formatArrayAsString($exceptionsNotImplementingInterface)); } /** * @param string $ruleName + * * @return string */ private function buildExceptionClass($ruleName) { - $exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception'; + $exceptionClass = 'Respect\\Validation\\Exceptions\\'.$ruleName.'Exception'; + return $exceptionClass; } /** * @param array $array + * * @return string */ private function formatArrayAsString(array $array) diff --git a/tests/Exceptions/ValidationExceptionTest.php b/tests/Exceptions/ValidationExceptionTest.php index f8dea2c3..e5c54a37 100644 --- a/tests/Exceptions/ValidationExceptionTest.php +++ b/tests/Exceptions/ValidationExceptionTest.php @@ -1,4 +1,5 @@ setParam('foo', $input); $this->assertEquals( $expected, @@ -84,9 +85,9 @@ class ValidationExceptionTest extends \PHPUnit_Framework_TestCase return array( array('foo', 'foo'), array(123, '123'), - array(array(), "Array"), - array(new \stdClass, "Object of class stdClass"), - array($x = new \DateTime, $x->format('Y-m-d H:i:s')), + array(array(), 'Array'), + array(new \stdClass(), 'Object of class stdClass'), + array($x = new \DateTime(), $x->format('Y-m-d H:i:s')), ); } @@ -96,18 +97,18 @@ class ValidationExceptionTest extends \PHPUnit_Framework_TestCase array( '{{foo}} {{bar}} {{baz}}', 'hello world respect', - array('foo' => 'hello', 'bar' => 'world', 'baz' => 'respect') + array('foo' => 'hello', 'bar' => 'world', 'baz' => 'respect'), ), array( '{{foo}} {{bar}} {{baz}}', 'hello {{bar}} respect', - array('foo' => 'hello', 'baz' => 'respect') + array('foo' => 'hello', 'baz' => 'respect'), ), array( '{{foo}} {{bar}} {{baz}}', 'hello {{bar}} respect', - array('foo' => 'hello', 'bot' => 111, 'baz' => 'respect') - ) + array('foo' => 'hello', 'bot' => 111, 'baz' => 'respect'), + ), ); } } diff --git a/tests/Rules/AbstractCompositeTest.php b/tests/Rules/AbstractCompositeTest.php index 9d4d0fbc..374f7e68 100644 --- a/tests/Rules/AbstractCompositeTest.php +++ b/tests/Rules/AbstractCompositeTest.php @@ -1,4 +1,5 @@ removeRules(); $this->assertEquals(0, count($o->getRules())); } @@ -15,7 +16,7 @@ class AllOfTest extends \PHPUnit_Framework_TestCase $o = new AllOf(); $o->addRules( array( - array($x = new Int, new Positive) + array($x = new Int(), new Positive()), ) ); $this->assertTrue($o->hasRule($x)); @@ -25,19 +26,19 @@ class AllOfTest extends \PHPUnit_Framework_TestCase public function testAddRulesUsingSpecificationArray() { $o = new AllOf(); - $o->addRules(array("Between" => array(1, 2))); + $o->addRules(array('Between' => array(1, 2))); $this->assertTrue($o->hasRule('Between')); } public function testValidationShouldWorkIfAllRulesReturnTrue() { - $valid1 = new Callback(function() { + $valid1 = new Callback(function () { return true; }); - $valid2 = new Callback(function() { + $valid2 = new Callback(function () { return true; }); - $valid3 = new Callback(function() { + $valid3 = new Callback(function () { return true; }); $o = new AllOf($valid1, $valid2, $valid3); @@ -93,13 +94,13 @@ class AllOfTest extends \PHPUnit_Framework_TestCase public function providerStaticDummyRules() { - $theInvalidOne = new Callback(function() { + $theInvalidOne = new Callback(function () { return false; }); - $valid1 = new Callback(function() { + $valid1 = new Callback(function () { return true; }); - $valid2 = new Callback(function() { + $valid2 = new Callback(function () { return true; }); @@ -108,8 +109,7 @@ class AllOfTest extends \PHPUnit_Framework_TestCase array($valid2, $valid1, $theInvalidOne), array($valid2, $theInvalidOne, $valid1), array($valid1, $valid2, $theInvalidOne), - array($valid1, $theInvalidOne, $valid2) + array($valid1, $theInvalidOne, $valid2), ); } } - diff --git a/tests/Rules/AlnumTest.php b/tests/Rules/AlnumTest.php index 8983d427..b4531108 100644 --- a/tests/Rules/AlnumTest.php +++ b/tests/Rules/AlnumTest.php @@ -1,4 +1,5 @@ assert(''); diff --git a/tests/Rules/ArrTest.php b/tests/Rules/ArrTest.php index 49756d6f..b3f92822 100644 --- a/tests/Rules/ArrTest.php +++ b/tests/Rules/ArrTest.php @@ -1,4 +1,5 @@ object = new Arr; + $this->object = new Arr(); } /** @@ -40,16 +41,15 @@ class ArrTest extends \PHPUnit_Framework_TestCase array(''), array(array()), array(array(1, 2, 3)), - array(new TestAccess), + array(new TestAccess()), ); - $validator = v::alnum()->length(1,10); + $validator = v::alnum()->length(1, 10); $validator = new \Respect\Validation\Rules\AllOf( new Respect\Validation\Rules\Alnum(), - new Respect\Validation\Rules\Length(1,10) + new Respect\Validation\Rules\Length(1, 10) ); - } public function providerForNotArray() @@ -57,10 +57,9 @@ class ArrTest extends \PHPUnit_Framework_TestCase return array( array(null), array(121), - array(new \stdClass), + array(new \stdClass()), array(false), array('aaa'), ); } } - diff --git a/tests/Rules/AttributeTest.php b/tests/Rules/AttributeTest.php index 70b0ac7b..cdc86c9d 100644 --- a/tests/Rules/AttributeTest.php +++ b/tests/Rules/AttributeTest.php @@ -1,4 +1,5 @@ bar = 'foo'; $this->assertTrue($validator->check($obj)); $this->assertTrue($validator->__invoke($obj)); @@ -24,7 +25,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase public function testAbsentAttributeShouldRaiseAttributeException() { $validator = new Attribute('bar'); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->baraaaaa = 'foo'; $this->assertFalse($validator->__invoke($obj)); $this->assertFalse($validator->assert($obj)); @@ -35,7 +36,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase public function testAbsentAttributeShouldRaiseAttributeException_on_check() { $validator = new Attribute('bar'); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->baraaaaa = 'foo'; $this->assertFalse($validator->__invoke($obj)); $this->assertFalse($validator->check($obj)); @@ -53,9 +54,9 @@ class AttributeTest extends \PHPUnit_Framework_TestCase public function providerForInvalidAttributeNames() { return array( - array(new \stdClass), + array(new \stdClass()), array(123), - array('') + array(''), ); } @@ -63,7 +64,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->bar = 'foo'; $this->assertTrue($validator->__invoke($obj)); $this->assertTrue($validator->assert($obj)); @@ -77,7 +78,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->bar = 'foo hey this has more than 3 chars'; $this->assertFalse($validator->__invoke($obj)); } @@ -89,7 +90,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->bar = 'foo hey this has more than 3 chars'; $this->assertFalse($validator->check($obj)); } @@ -100,7 +101,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator); - $obj = new \stdClass; + $obj = new \stdClass(); $obj->bar = 'foo hey this has more than 3 chars'; $this->assertFalse($validator->assert($obj)); } @@ -108,7 +109,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase public function testNotMandatoryAttributeShouldNotFailWhenAttributeIsAbsent() { $validator = new Attribute('bar', null, false); - $obj = new \stdClass; + $obj = new \stdClass(); $this->assertTrue($validator->__invoke($obj)); } @@ -116,7 +117,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator, false); - $obj = new \stdClass; + $obj = new \stdClass(); $this->assertTrue($validator->__invoke($obj)); } @@ -124,7 +125,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(1, 3); $validator = new Attribute('bar', $subValidator); - $obj = new PrivClass; + $obj = new PrivClass(); $this->assertTrue($validator->assert($obj)); } @@ -132,8 +133,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { $subValidator = new Length(33333, 888888); $validator = new Attribute('bar', $subValidator); - $obj = new PrivClass; + $obj = new PrivClass(); $this->assertFalse($validator->__invoke($obj)); } } - diff --git a/tests/Rules/BankAccountTest.php b/tests/Rules/BankAccountTest.php index 1e77f429..2d8b4a8d 100644 --- a/tests/Rules/BankAccountTest.php +++ b/tests/Rules/BankAccountTest.php @@ -1,4 +1,5 @@ getMock('Respect\Validation\Validatable'); - $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); + $validatable = $this->getMock('Respect\Validation\Validatable'); + $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); $factory ->expects($this->once()) ->method('bankAccount') ->with($countryCode, $bank) ->will($this->returnValue($validatable)); - $rule = new BankAccount($countryCode, $bank, $factory); + $rule = new BankAccount($countryCode, $bank, $factory); $this->assertSame($validatable, $rule->getValidatable()); } public function testShouldUseDefaultFactoryToCreateInternalRuleBasedOnGivenCountryCodeWhenFactoryIsNotDefined() { - $countryCode = 'DE'; - $bank = '123456'; - $rule = new BankAccount($countryCode, $bank); + $countryCode = 'DE'; + $bank = '123456'; + $rule = new BankAccount($countryCode, $bank); $this->assertInstanceOf('Respect\Validation\Rules\Locale\GermanBankAccount', $rule->getValidatable()); } diff --git a/tests/Rules/BankTest.php b/tests/Rules/BankTest.php index c02773bc..524f61fb 100644 --- a/tests/Rules/BankTest.php +++ b/tests/Rules/BankTest.php @@ -1,4 +1,5 @@ getMock('Respect\Validation\Validatable'); - $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); + $validatable = $this->getMock('Respect\Validation\Validatable'); + $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); $factory ->expects($this->once()) ->method('bank') ->with($countryCode) ->will($this->returnValue($validatable)); - $rule = new Bank($countryCode, $factory); + $rule = new Bank($countryCode, $factory); $this->assertSame($validatable, $rule->getValidatable()); } public function testShouldUseDefaultFactoryToCreateInternalRuleBasedOnGivenCountryCodeWhenFactoryIsNotDefined() { - $countryCode = 'DE'; - $rule = new Bank($countryCode); + $countryCode = 'DE'; + $rule = new Bank($countryCode); $this->assertInstanceOf('Respect\Validation\Rules\Locale\GermanBank', $rule->getValidatable()); } diff --git a/tests/Rules/BaseTest.php b/tests/Rules/BaseTest.php index 5e497191..5c1246ac 100644 --- a/tests/Rules/BaseTest.php +++ b/tests/Rules/BaseTest.php @@ -1,7 +1,6 @@ getMock('Respect\Validation\Validatable'); - $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); + $validatable = $this->getMock('Respect\Validation\Validatable'); + $factory = $this->getMock('Respect\Validation\Rules\Locale\Factory'); $factory ->expects($this->once()) ->method('bic') ->with($countryCode) ->will($this->returnValue($validatable)); - $rule = new Bic($countryCode, $factory); + $rule = new Bic($countryCode, $factory); $this->assertSame($validatable, $rule->getValidatable()); } public function testShouldUseDefaultFactoryToCreateInternalRuleBasedOnGivenCountryCodeWhenFactoryIsNotDefined() { - $countryCode = 'DE'; - $rule = new Bic($countryCode); + $countryCode = 'DE'; + $rule = new Bic($countryCode); $this->assertInstanceOf('Respect\Validation\Rules\Locale\GermanBic', $rule->getValidatable()); } diff --git a/tests/Rules/BoolTest.php b/tests/Rules/BoolTest.php index 8e3a0369..c4e4f340 100644 --- a/tests/Rules/BoolTest.php +++ b/tests/Rules/BoolTest.php @@ -1,4 +1,5 @@ assertFalse($validator->__invoke(null)); } } - diff --git a/tests/Rules/CallTest.php b/tests/Rules/CallTest.php index c4a7d575..3c40e2ae 100644 --- a/tests/Rules/CallTest.php +++ b/tests/Rules/CallTest.php @@ -1,4 +1,5 @@ assertTrue($v->assert('')); } public function testCallbackValidatorShouldAcceptStringWithFunctionName() { - $v = new Call('str_split', new Arr); + $v = new Call('str_split', new Arr()); $this->assertTrue($v->assert('test')); } public function testCallbackValidatorShouldAcceptArrayCallbackDefinition() { - $v = new Call(array($this, 'thisIsASampleCallbackUsedInsideThisTest'), new Arr); + $v = new Call(array($this, 'thisIsASampleCallbackUsedInsideThisTest'), new Arr()); $this->assertTrue($v->assert('test')); } public function testCallbackValidatorShouldAcceptClosures() { - $v = new Call(function() { + $v = new Call(function () { return array(); - }, new Arr); + }, new Arr()); $this->assertTrue($v->assert('test')); } @@ -39,9 +40,8 @@ class CallTest extends \PHPUnit_Framework_TestCase */ public function testCallbackFailedShouldThrowCallException() { - $v = new Call('strrev', new Arr); + $v = new Call('strrev', new Arr()); $this->assertFalse($v->validate('test')); $this->assertFalse($v->assert('test')); } } - diff --git a/tests/Rules/CallbackTest.php b/tests/Rules/CallbackTest.php index 9614e30a..90ac9ebf 100644 --- a/tests/Rules/CallbackTest.php +++ b/tests/Rules/CallbackTest.php @@ -1,15 +1,17 @@ truthy = new Callback(function() { + public function setUp() + { + $this->truthy = new Callback(function () { return true; }); - $this->falsy = new Callback(function() { + $this->falsy = new Callback(function () { return false; }); } @@ -62,8 +64,7 @@ class CallbackTest extends \PHPUnit_Framework_TestCase */ public function testInvalidCallbacksShouldRaiseComponentExceptionUponInstantiation() { - $v = new Callback(new \stdClass); + $v = new Callback(new \stdClass()); $this->assertTrue($v->assert('w poiur')); } } - diff --git a/tests/Rules/CharsetTest.php b/tests/Rules/CharsetTest.php index 317d0847..d6087683 100644 --- a/tests/Rules/CharsetTest.php +++ b/tests/Rules/CharsetTest.php @@ -1,4 +1,5 @@ cnhValidator = new Cnh; + $this->cnhValidator = new Cnh(); } /** @@ -171,4 +172,3 @@ class CnhTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/CnpjTest.php b/tests/Rules/CnpjTest.php index b4337052..d0b4a52c 100644 --- a/tests/Rules/CnpjTest.php +++ b/tests/Rules/CnpjTest.php @@ -1,4 +1,5 @@ cnpjValidator = new Cnpj; + $this->cnpjValidator = new Cnpj(); } /** @@ -99,7 +100,7 @@ class CnpjTest extends \PHPUnit_Framework_TestCase array('12345678900'), array('99299929384'), array('84434895894'), - array('44242340000') + array('44242340000'), ); } @@ -110,8 +111,7 @@ class CnpjTest extends \PHPUnit_Framework_TestCase array('22'), array('123'), array('992999999999929384'), - array('99-010-0.') + array('99-010-0.'), ); } } - diff --git a/tests/Rules/CntrlTest.php b/tests/Rules/CntrlTest.php index 0b68d6bf..853f2abf 100644 --- a/tests/Rules/CntrlTest.php +++ b/tests/Rules/CntrlTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validCntrl)); @@ -16,7 +17,7 @@ class CntrlTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidCntrl * @expectedException Respect\Validation\Exceptions\CntrlException */ - public function testInvalidCntrlShouldFailAndThrowCntrlException($invalidCntrl, $additional='') + public function testInvalidCntrlShouldFailAndThrowCntrlException($invalidCntrl, $additional = '') { $validator = new Cntrl($additional); $this->assertFalse($validator->validate($invalidCntrl)); @@ -52,9 +53,9 @@ class CntrlTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -84,4 +85,3 @@ class CntrlTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/ConsonantTest.php b/tests/Rules/ConsonantTest.php index 15a58e51..ec4afcc0 100644 --- a/tests/Rules/ConsonantTest.php +++ b/tests/Rules/ConsonantTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validConsonants)); @@ -16,7 +17,7 @@ class ConsonantTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidConsonants * @expectedException Respect\Validation\Exceptions\ConsonantException */ - public function testInvalidConsonantsShouldFailAndThrowConsonantException($invalidConsonants, $additional='') + public function testInvalidConsonantsShouldFailAndThrowConsonantException($invalidConsonants, $additional = '') { $validator = new Consonant($additional); $this->assertFalse($validator->validate($invalidConsonants)); @@ -52,9 +53,9 @@ class ConsonantTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -89,4 +90,3 @@ class ConsonantTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/ContainsTest.php b/tests/Rules/ContainsTest.php index 94ed3fcc..bd2b70a0 100644 --- a/tests/Rules/ContainsTest.php +++ b/tests/Rules/ContainsTest.php @@ -1,4 +1,5 @@ assertFalse($v->__invoke($input)); @@ -48,4 +49,3 @@ class ContainsTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/CpfTest.php b/tests/Rules/CpfTest.php index a8b02fd1..a0f392a3 100644 --- a/tests/Rules/CpfTest.php +++ b/tests/Rules/CpfTest.php @@ -1,4 +1,5 @@ cpfValidator = new Cpf; + $this->cpfValidator = new Cpf(); } /** @@ -61,7 +62,7 @@ class CpfTest extends \PHPUnit_Framework_TestCase array('342.444.198.88'), array('350.45261819'), array('693-319-118-40'), - array('3.6.8.8.9.2.5.5.4.8.8') + array('3.6.8.8.9.2.5.5.4.8.8'), ); } @@ -85,7 +86,7 @@ class CpfTest extends \PHPUnit_Framework_TestCase array('999999999.99'), array('8.8.8.8.8.8.8.8.8.8.8'), array('693-319-110-40'), - array('698.111-111.00') + array('698.111-111.00'), ); } @@ -97,7 +98,7 @@ class CpfTest extends \PHPUnit_Framework_TestCase array('12345678900'), array('99299929384'), array('84434895894'), - array('44242340000') + array('44242340000'), ); } @@ -111,4 +112,3 @@ class CpfTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/CreditCardTest.php b/tests/Rules/CreditCardTest.php index b71ba1d1..0d5ede7a 100644 --- a/tests/Rules/CreditCardTest.php +++ b/tests/Rules/CreditCardTest.php @@ -1,4 +1,5 @@ creditCardValidator = new CreditCard; + $this->creditCardValidator = new CreditCard(); } /** * @dataProvider providerForCreditCard - * */ public function testValidCreditCardsShouldReturnTrue($input) { @@ -54,4 +54,3 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/DateTest.php b/tests/Rules/DateTest.php index 33188e18..804ec067 100644 --- a/tests/Rules/DateTest.php +++ b/tests/Rules/DateTest.php @@ -1,4 +1,5 @@ dateValidator = new Date; + $this->dateValidator = new Date(); } public function testDateEmptyShouldValidate() @@ -41,7 +42,7 @@ class DateTest extends \PHPUnit_Framework_TestCase public function testAnyObjectExceptDateTimeInstancesShouldFail() { - $this->assertFalse($this->dateValidator->__invoke(new \stdClass)); + $this->assertFalse($this->dateValidator->__invoke(new \stdClass())); } public function testFormatsShouldValidateDateStrings() @@ -88,19 +89,17 @@ class DateTest extends \PHPUnit_Framework_TestCase } /** - * * @return array */ - public function providerForDateTimeTimezoneStrings(){ + public function providerForDateTimeTimezoneStrings() + { return array( - array('UTC', 'c', '2005-12-30T01:02:03+01:00',), - array('UTC', 'c', '2004-02-12T15:19:21+00:00',), - array('UTC', 'r', 'Thu, 29 Dec 2005 01:02:03 +0000',), - array('Europe/Amsterdam', 'c', '2005-12-30T01:02:03+01:00',), - array('Europe/Amsterdam', 'c', '2004-02-12T15:19:21+00:00',), - array('Europe/Amsterdam', 'r', 'Thu, 29 Dec 2005 01:02:03 +0000',), + array('UTC', 'c', '2005-12-30T01:02:03+01:00'), + array('UTC', 'c', '2004-02-12T15:19:21+00:00'), + array('UTC', 'r', 'Thu, 29 Dec 2005 01:02:03 +0000'), + array('Europe/Amsterdam', 'c', '2005-12-30T01:02:03+01:00'), + array('Europe/Amsterdam', 'c', '2004-02-12T15:19:21+00:00'), + array('Europe/Amsterdam', 'r', 'Thu, 29 Dec 2005 01:02:03 +0000'), ); } - } - diff --git a/tests/Rules/DigitTest.php b/tests/Rules/DigitTest.php index b6c16179..4475475e 100644 --- a/tests/Rules/DigitTest.php +++ b/tests/Rules/DigitTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validDigits)); @@ -16,7 +17,7 @@ class DigitTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidDigits * @expectedException Respect\Validation\Exceptions\DigitException */ - public function testInvalidDigitsShouldFailAndThrowDigitException($invalidDigits, $additional='') + public function testInvalidDigitsShouldFailAndThrowDigitException($invalidDigits, $additional = '') { $validator = new Digit($additional); $this->assertFalse($validator->validate($invalidDigits)); @@ -52,9 +53,9 @@ class DigitTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -88,4 +89,3 @@ class DigitTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/DirectoryTest.php b/tests/Rules/DirectoryTest.php index 2ee8600b..0720ca36 100644 --- a/tests/Rules/DirectoryTest.php +++ b/tests/Rules/DirectoryTest.php @@ -1,4 +1,5 @@ object = new Domain; + $this->object = new Domain(); } /** * @dataProvider providerForDomain - * */ - public function testValidDomainsShouldReturnTrue($input, $tldcheck=true) + public function testValidDomainsShouldReturnTrue($input, $tldcheck = true) { $this->object->tldCheck($tldcheck); $this->assertTrue($this->object->__invoke($input)); @@ -28,7 +28,7 @@ class DomainTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForNotDomain * @expectedException Respect\Validation\Exceptions\ValidationException */ - public function testNotDomain($input, $tldcheck=true) + public function testNotDomain($input, $tldcheck = true) { $this->object->tldCheck($tldcheck); $this->assertFalse($this->object->check($input)); @@ -38,7 +38,7 @@ class DomainTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForNotDomain * @expectedException Respect\Validation\Exceptions\DomainException */ - public function testNotDomainCheck($input, $tldcheck=true) + public function testNotDomainCheck($input, $tldcheck = true) { $this->object->tldCheck($tldcheck); $this->assertFalse($this->object->assert($input)); @@ -74,7 +74,7 @@ class DomainTest extends \PHPUnit_Framework_TestCase /** * @dataProvider providerForDomain */ - public function testBuilder($validDomain, $checkTLD=true) + public function testBuilder($validDomain, $checkTLD = true) { $this->assertTrue( v::domain($checkTLD)->validate($validDomain), @@ -82,4 +82,3 @@ class DomainTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/EachTest.php b/tests/Rules/EachTest.php index 855ffeda..8cfcbd25 100644 --- a/tests/Rules/EachTest.php +++ b/tests/Rules/EachTest.php @@ -1,4 +1,5 @@ assertFalse($result); } } - diff --git a/tests/Rules/EmailTest.php b/tests/Rules/EmailTest.php index 5b226d27..a48e9184 100644 --- a/tests/Rules/EmailTest.php +++ b/tests/Rules/EmailTest.php @@ -1,4 +1,5 @@ assertFalse($v->__invoke($input)); @@ -51,4 +52,3 @@ class EndsWithTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/EqualsTest.php b/tests/Rules/EqualsTest.php index b9a8aa34..f77afd97 100644 --- a/tests/Rules/EqualsTest.php +++ b/tests/Rules/EqualsTest.php @@ -1,4 +1,5 @@ assertFalse($v->__invoke($input)); @@ -30,7 +31,7 @@ class EqualsTest extends \PHPUnit_Framework_TestCase return array( array('foo', ''), array('foo', 'foo'), - array(10, "10"), + array(10, '10'), ); } @@ -38,8 +39,7 @@ class EqualsTest extends \PHPUnit_Framework_TestCase { return array( array('foo', 'bar'), - array(10, "10", true), + array(10, '10', true), ); } } - diff --git a/tests/Rules/EvenTest.php b/tests/Rules/EvenTest.php index fc7d3feb..e8d69799 100644 --- a/tests/Rules/EvenTest.php +++ b/tests/Rules/EvenTest.php @@ -1,4 +1,5 @@ evenValidator = new Even; + $this->evenValidator = new Even(); } /** @@ -51,4 +52,3 @@ class EvenTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/ExistsTest.php b/tests/Rules/ExistsTest.php index 66ea286b..fe61de0d 100644 --- a/tests/Rules/ExistsTest.php +++ b/tests/Rules/ExistsTest.php @@ -8,7 +8,7 @@ function file_exists($file) { $return = \file_exists($file); // Running the real function if (null !== $GLOBALS['file_exists']) { - $return = $GLOBALS['file_exists']; + $return = $GLOBALS['file_exists']; $GLOBALS['file_exists'] = null; } @@ -17,7 +17,6 @@ function file_exists($file) class ExistsTest extends \PHPUnit_Framework_TestCase { - /** * @covers Respect\Validation\Rules\Exists::validate */ @@ -54,5 +53,4 @@ class ExistsTest extends \PHPUnit_Framework_TestCase $this->assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/FalseTest.php b/tests/Rules/FalseTest.php index 5405af95..f406420d 100644 --- a/tests/Rules/FalseTest.php +++ b/tests/Rules/FalseTest.php @@ -1,4 +1,5 @@ assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/FilterVarTest.php b/tests/Rules/FilterVarTest.php index baa99089..eefdc906 100644 --- a/tests/Rules/FilterVarTest.php +++ b/tests/Rules/FilterVarTest.php @@ -1,4 +1,5 @@ floatValidator = new Float; + $this->floatValidator = new Float(); } /** @@ -56,4 +57,3 @@ class FloatTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/GraphTest.php b/tests/Rules/GraphTest.php index 4901d16a..563a37d4 100644 --- a/tests/Rules/GraphTest.php +++ b/tests/Rules/GraphTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validGraph)); @@ -16,7 +17,7 @@ class GraphTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidGraph * @expectedException Respect\Validation\Exceptions\GraphException */ - public function testInvalidGraphShouldFailAndThrowGraphException($invalidGraph, $additional='') + public function testInvalidGraphShouldFailAndThrowGraphException($invalidGraph, $additional = '') { $validator = new Graph($additional); $this->assertFalse($validator->validate($invalidGraph)); @@ -52,9 +53,9 @@ class GraphTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -81,4 +82,3 @@ class GraphTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/HexRgbColorTest.php b/tests/Rules/HexRgbColorTest.php index 4506d350..d484aae6 100644 --- a/tests/Rules/HexRgbColorTest.php +++ b/tests/Rules/HexRgbColorTest.php @@ -1,4 +1,5 @@ hexaValidator = new Hexa; + $this->hexaValidator = new Hexa(); } protected function tearDown() @@ -59,4 +60,3 @@ class HexaTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/InTest.php b/tests/Rules/InTest.php index 21c95f3e..a62eef63 100644 --- a/tests/Rules/InTest.php +++ b/tests/Rules/InTest.php @@ -1,13 +1,13 @@ assertTrue($v->__invoke($input)); @@ -19,7 +19,7 @@ class InTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForNotIn * @expectedException Respect\Validation\Exceptions\InException */ - public function testInvalidInChecksShouldThrowInException($input, $options, $strict=false) + public function testInvalidInChecksShouldThrowInException($input, $options, $strict = false) { $v = new In($options, $strict); $this->assertFalse($v->__invoke($input)); @@ -50,4 +50,3 @@ class InTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/InstanceTest.php b/tests/Rules/InstanceTest.php index 02ed17ed..92325403 100644 --- a/tests/Rules/InstanceTest.php +++ b/tests/Rules/InstanceTest.php @@ -1,4 +1,5 @@ assertTrue($this->instanceValidator->__invoke('')); $this->assertTrue($this->instanceValidator->assert('')); $this->assertTrue($this->instanceValidator->check('')); - $this->assertTrue($this->instanceValidator->__invoke(new \ArrayObject)); - $this->assertTrue($this->instanceValidator->assert(new \ArrayObject)); - $this->assertTrue($this->instanceValidator->check(new \ArrayObject)); + $this->assertTrue($this->instanceValidator->__invoke(new \ArrayObject())); + $this->assertTrue($this->instanceValidator->assert(new \ArrayObject())); + $this->assertTrue($this->instanceValidator->check(new \ArrayObject())); } /** @@ -25,8 +26,7 @@ class InstanceTest extends \PHPUnit_Framework_TestCase */ public function testInvalidInstancesShouldThrowInstanceException() { - $this->assertFalse($this->instanceValidator->validate(new \stdClass)); - $this->assertFalse($this->instanceValidator->assert(new \stdClass)); + $this->assertFalse($this->instanceValidator->validate(new \stdClass())); + $this->assertFalse($this->instanceValidator->assert(new \stdClass())); } } - diff --git a/tests/Rules/IntTest.php b/tests/Rules/IntTest.php index 5acc10c9..ca6d4059 100644 --- a/tests/Rules/IntTest.php +++ b/tests/Rules/IntTest.php @@ -1,4 +1,5 @@ intValidator = new Int; + $this->intValidator = new Int(); } /** * @dataProvider providerForInt - * */ public function testValidIntegersShouldReturnTrue($input) { @@ -54,4 +54,3 @@ class IntTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/IpTest.php b/tests/Rules/IpTest.php index eef063fc..577e6949 100644 --- a/tests/Rules/IpTest.php +++ b/tests/Rules/IpTest.php @@ -1,13 +1,13 @@ assertTrue($ipValidator->__invoke($input)); @@ -30,7 +30,7 @@ class IpTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForNotIp * @expectedException Respect\Validation\Exceptions\IpException */ - public function testInvalidIpsShouldThrowIpException($input, $options=null) + public function testInvalidIpsShouldThrowIpException($input, $options = null) { $ipValidator = new Ip($options); $this->assertFalse($ipValidator->__invoke($input)); @@ -127,4 +127,3 @@ class IpTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/JsonTest.php b/tests/Rules/JsonTest.php index a3f4e00d..ff08340c 100644 --- a/tests/Rules/JsonTest.php +++ b/tests/Rules/JsonTest.php @@ -1,4 +1,5 @@ json = new Json; + $this->json = new Json(); } /** @@ -25,8 +26,8 @@ class JsonTest extends \PHPUnit_Framework_TestCase */ public function testInvalidJsonsShouldThrowJsonException() { - $this->assertFalse($this->json->__invoke("{foo:bar}")); - $this->assertFalse($this->json->assert("{foo:bar}")); + $this->assertFalse($this->json->__invoke('{foo:bar}')); + $this->assertFalse($this->json->assert('{foo:bar}')); } public function providerForPass() @@ -44,6 +45,4 @@ class JsonTest extends \PHPUnit_Framework_TestCase array('null'), ); } - } - diff --git a/tests/Rules/KeyTest.php b/tests/Rules/KeyTest.php index a6d29204..afbd2881 100644 --- a/tests/Rules/KeyTest.php +++ b/tests/Rules/KeyTest.php @@ -1,4 +1,5 @@ ''); + $rule = new Key('key', new NotEmpty()); + $input = array('key' => ''); try { $rule->assert($input); $this->fail('`assert()` must throws exception'); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } try { $rule->check($input); $this->fail('`check()` must throws exception'); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } $this->assertFalse($rule->validate($input)); } @@ -97,4 +100,3 @@ class KeyTest extends \PHPUnit_Framework_TestCase $this->assertTrue($validator->validate($obj)); } } - diff --git a/tests/Rules/LeapDateTest.php b/tests/Rules/LeapDateTest.php index 364fc04f..becf7800 100644 --- a/tests/Rules/LeapDateTest.php +++ b/tests/Rules/LeapDateTest.php @@ -1,4 +1,5 @@ assertFalse($this->leapDateValidator->validate(array())); } } - diff --git a/tests/Rules/LeapYearTest.php b/tests/Rules/LeapYearTest.php index 4e97b77e..42536f75 100644 --- a/tests/Rules/LeapYearTest.php +++ b/tests/Rules/LeapYearTest.php @@ -1,4 +1,5 @@ leapYearValidator = new LeapYear; + $this->leapYearValidator = new LeapYear(); } public function testValidLeapDate() @@ -32,4 +33,3 @@ class LeapYearTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->leapYearValidator->__invoke(array())); } } - diff --git a/tests/Rules/LengthTest.php b/tests/Rules/LengthTest.php index 964ebcea..0fa7ab68 100644 --- a/tests/Rules/LengthTest.php +++ b/tests/Rules/LengthTest.php @@ -1,4 +1,5 @@ 'bar', 'bar'=>'baz'), 1, 2), + array((object) array('foo' => 'bar', 'bar' => 'baz'), 1, 2), array('alganet', 1, null), //null is a valid max length, means "no maximum", - array('alganet', null, 15) //null is a valid min length, means "no minimum" + array('alganet', null, 15), //null is a valid min length, means "no minimum" ); } @@ -66,7 +67,7 @@ class LengthTest extends \PHPUnit_Framework_TestCase array('alganet', 1, 7), array(range(1, 20), 1, 20), array('alganet', 7, null), //null is a valid max length, means "no maximum", - array('alganet', null, 7) //null is a valid min length, means "no minimum" + array('alganet', null, 7), //null is a valid min length, means "no minimum" ); } @@ -74,7 +75,7 @@ class LengthTest extends \PHPUnit_Framework_TestCase { return array( array('alganet', 1, 3), - array((object) array('foo'=>'bar', 'bar'=>'baz'), 3, 5), + array((object) array('foo' => 'bar', 'bar' => 'baz'), 3, 5), array(range(1, 50), 1, 30), ); } @@ -88,4 +89,3 @@ class LengthTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/Locale/FactoryTest.php b/tests/Rules/Locale/FactoryTest.php index e1dde4b4..ac9fe2da 100644 --- a/tests/Rules/Locale/FactoryTest.php +++ b/tests/Rules/Locale/FactoryTest.php @@ -1,4 +1,5 @@ getBavMock(); + $bav = $this->getBavMock(); $rule = new GermanBankAccount($bank, $bav); $this->assertSame($bav, $rule->bav); @@ -36,10 +37,10 @@ class GermanBankAccountTest extends LocaleTestCase public function testShouldUseBAVInstanceToValidate() { - $bank = '10000000'; - $input = '67067'; - $bav = $this->getBavMock(); - $rule = new GermanBankAccount($bank, $bav); + $bank = '10000000'; + $input = '67067'; + $bav = $this->getBavMock(); + $rule = new GermanBankAccount($bank, $bav); $bav->expects($this->once()) ->method('isValidBankAccount') @@ -51,10 +52,10 @@ class GermanBankAccountTest extends LocaleTestCase public function testShouldReturnBAVInstanceResulteWhenValidating() { - $bank = '10000000'; - $input = '67067'; - $bav = $this->getBavMock(); - $rule = new GermanBankAccount($bank, $bav); + $bank = '10000000'; + $input = '67067'; + $bav = $this->getBavMock(); + $rule = new GermanBankAccount($bank, $bav); $bav->expects($this->any()) ->method('isValidBankAccount') @@ -70,10 +71,10 @@ class GermanBankAccountTest extends LocaleTestCase */ public function testShouldThowsTheRightExceptionWhenChecking() { - $bank = '10000000'; - $input = '67067'; - $bav = $this->getBavMock(); - $rule = new GermanBankAccount($bank, $bav); + $bank = '10000000'; + $input = '67067'; + $bav = $this->getBavMock(); + $rule = new GermanBankAccount($bank, $bav); $bav->expects($this->any()) ->method('isValidBankAccount') diff --git a/tests/Rules/Locale/GermanBankTest.php b/tests/Rules/Locale/GermanBankTest.php index aed62259..0632c89d 100644 --- a/tests/Rules/Locale/GermanBankTest.php +++ b/tests/Rules/Locale/GermanBankTest.php @@ -1,4 +1,5 @@ getBavMock(); + $bav = $this->getBavMock(); $rule = new GermanBank($bav); $this->assertSame($bav, $rule->bav); @@ -26,9 +27,9 @@ class GermanBankTest extends LocaleTestCase public function testShouldUseBAVInstanceToValidate() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBank($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBank($bav); $bav->expects($this->once()) ->method('isValidBank') @@ -40,9 +41,9 @@ class GermanBankTest extends LocaleTestCase public function testShouldReturnBAVInstanceResulteWhenValidating() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBank($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBank($bav); $bav->expects($this->any()) ->method('isValidBank') @@ -58,9 +59,9 @@ class GermanBankTest extends LocaleTestCase */ public function testShouldThowsTheRightExceptionWhenChecking() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBank($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBank($bav); $bav->expects($this->any()) ->method('isValidBank') diff --git a/tests/Rules/Locale/GermanBicTest.php b/tests/Rules/Locale/GermanBicTest.php index 4b1865e5..7d784164 100644 --- a/tests/Rules/Locale/GermanBicTest.php +++ b/tests/Rules/Locale/GermanBicTest.php @@ -1,4 +1,5 @@ getBavMock(); + $bav = $this->getBavMock(); $rule = new GermanBic($bav); $this->assertSame($bav, $rule->bav); @@ -26,9 +27,9 @@ class GermanBicTest extends LocaleTestCase public function testShouldUseBAVInstanceToValidate() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBic($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBic($bav); $bav->expects($this->once()) ->method('isValidBIC') @@ -40,9 +41,9 @@ class GermanBicTest extends LocaleTestCase public function testShouldReturnBAVInstanceResulteWhenValidating() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBic($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBic($bav); $bav->expects($this->any()) ->method('isValidBIC') @@ -58,9 +59,9 @@ class GermanBicTest extends LocaleTestCase */ public function testShouldThowsTheRightExceptionWhenChecking() { - $input = '10000000'; - $bav = $this->getBavMock(); - $rule = new GermanBic($bav); + $input = '10000000'; + $bav = $this->getBavMock(); + $rule = new GermanBic($bav); $bav->expects($this->any()) ->method('isValidBIC') diff --git a/tests/Rules/LowercaseTest.php b/tests/Rules/LowercaseTest.php index 5b933713..7a38f020 100644 --- a/tests/Rules/LowercaseTest.php +++ b/tests/Rules/LowercaseTest.php @@ -1,4 +1,5 @@ macaddressValidator = new MacAddress; + $this->macaddressValidator = new MacAddress(); } /** * @dataProvider providerForMacAddress - * */ public function testValidMacaddressesShouldReturnTrue($input) { @@ -52,4 +52,3 @@ class MacAddressTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/MaxTest.php b/tests/Rules/MaxTest.php index 15caaca9..b560713b 100644 --- a/tests/Rules/MaxTest.php +++ b/tests/Rules/MaxTest.php @@ -1,4 +1,5 @@ negativeValidator = new Negative; + $this->negativeValidator = new Negative(); } /** * @dataProvider providerForNegative - * */ public function testNegativeShouldPass($input) { @@ -57,4 +57,3 @@ class NegativeTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/NfeAccessKeyTest.php b/tests/Rules/NfeAccessKeyTest.php index 50875283..d8dc5f76 100644 --- a/tests/Rules/NfeAccessKeyTest.php +++ b/tests/Rules/NfeAccessKeyTest.php @@ -38,11 +38,11 @@ class NfeAccessKeyTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->nfeValidator->assert($aK)); } - + public function validAccessKeyProvider() { return array( - array('52060433009911002506550120000007800267301615') + array('52060433009911002506550120000007800267301615'), ); } @@ -57,7 +57,7 @@ class NfeAccessKeyTest extends \PHPUnit_Framework_TestCase array('90157126614010548506235171976891004177042525'), array('78457064241662300187501877048374851128754067'), array('39950148079977322431982386613620895568235903'), - array('90820939577654114875253907311677136672761216') + array('90820939577654114875253907311677136672761216'), ); } @@ -73,8 +73,7 @@ class NfeAccessKeyTest extends \PHPUnit_Framework_TestCase array('67229454773008929675906894698'), array('5858836670181917762140106857095788313119136'), array('6098412281885524361833754087461339281130'), - array('9025299113310221') + array('9025299113310221'), ); } } - diff --git a/tests/Rules/NoTest.php b/tests/Rules/NoTest.php index 02cd591a..7c40e4c9 100644 --- a/tests/Rules/NoTest.php +++ b/tests/Rules/NoTest.php @@ -1,4 +1,5 @@ noWhitespaceValidator = new NoWhitespace; + $this->noWhitespaceValidator = new NoWhitespace(); } /** diff --git a/tests/Rules/NoneOfTest.php b/tests/Rules/NoneOfTest.php index f2978248..c9d9c4bc 100644 --- a/tests/Rules/NoneOfTest.php +++ b/tests/Rules/NoneOfTest.php @@ -1,17 +1,18 @@ assertFalse($o->assert('any')); } } - diff --git a/tests/Rules/NotEmptyTest.php b/tests/Rules/NotEmptyTest.php index e3bc8056..4fcd11d0 100644 --- a/tests/Rules/NotEmptyTest.php +++ b/tests/Rules/NotEmptyTest.php @@ -1,4 +1,5 @@ object = new NotEmpty; + $this->object = new NotEmpty(); } /** @@ -34,7 +35,7 @@ class NotEmptyTest extends \PHPUnit_Framework_TestCase array(' oi'), array(array(5)), array(array(0)), - array(new \stdClass) + array(new \stdClass()), ); } @@ -46,8 +47,7 @@ class NotEmptyTest extends \PHPUnit_Framework_TestCase array("\n"), array(false), array(null), - array(array()) + array(array()), ); } } - diff --git a/tests/Rules/NotTest.php b/tests/Rules/NotTest.php index 58b7cb96..ecac4dd7 100644 --- a/tests/Rules/NotTest.php +++ b/tests/Rules/NotTest.php @@ -1,4 +1,5 @@ object = new NullValue; + $this->object = new NullValue(); } public function testNullValue() @@ -37,6 +38,4 @@ class NullValueTest extends \PHPUnit_Framework_TestCase array('Foo'), ); } - } - diff --git a/tests/Rules/NumericTest.php b/tests/Rules/NumericTest.php index fa33aa3d..d3d00c44 100644 --- a/tests/Rules/NumericTest.php +++ b/tests/Rules/NumericTest.php @@ -1,4 +1,5 @@ object = new Numeric; + $this->object = new Numeric(); } /** * @dataProvider providerForNumeric - * */ public function testNumeric($input) { @@ -54,4 +54,3 @@ class NumericTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/ObjectTest.php b/tests/Rules/ObjectTest.php index 184243a7..01e576a3 100644 --- a/tests/Rules/ObjectTest.php +++ b/tests/Rules/ObjectTest.php @@ -1,4 +1,5 @@ object = new Object; + $this->object = new Object(); } /** * @dataProvider providerForObject - * */ public function testObject($input) { @@ -35,8 +35,8 @@ class ObjectTest extends \PHPUnit_Framework_TestCase { return array( array(''), - array(new \stdClass), - array(new \ArrayObject), + array(new \stdClass()), + array(new \ArrayObject()), ); } @@ -51,4 +51,3 @@ class ObjectTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/OddTest.php b/tests/Rules/OddTest.php index 7636d849..f00c790b 100644 --- a/tests/Rules/OddTest.php +++ b/tests/Rules/OddTest.php @@ -1,4 +1,5 @@ object = new Odd; + $this->object = new Odd(); } /** * @dataProvider providerForOdd - * */ public function testOdd($input) { @@ -52,4 +52,3 @@ class OddTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/OneOfTest.php b/tests/Rules/OneOfTest.php index 0eee86ff..fe167bec 100644 --- a/tests/Rules/OneOfTest.php +++ b/tests/Rules/OneOfTest.php @@ -1,17 +1,18 @@ addOr($valid2, $valid3); @@ -82,7 +83,7 @@ class OneOfTest extends \PHPUnit_Framework_TestCase */ public function testInvalidCheck() { - $o = new OneOf(new Xdigit, new Alnum); + $o = new OneOf(new Xdigit(), new Alnum()); $this->assertFalse($o->validate(-10)); $this->assertFalse($o->check(-10)); } @@ -92,10 +93,9 @@ class OneOfTest extends \PHPUnit_Framework_TestCase */ public function testShortcutInvalidCheck() { - $xdigits = new Xdigit; - $o = $xdigits->addOr(new Alnum); + $xdigits = new Xdigit(); + $o = $xdigits->addOr(new Alnum()); $this->assertFalse($o->validate(-10)); $this->assertFalse($o->check(-10)); } } - diff --git a/tests/Rules/PerfectSquareTest.php b/tests/Rules/PerfectSquareTest.php index 38908674..4f6d1a41 100644 --- a/tests/Rules/PerfectSquareTest.php +++ b/tests/Rules/PerfectSquareTest.php @@ -1,4 +1,5 @@ object = new PerfectSquare; + $this->object = new PerfectSquare(); } /** * @dataProvider providerForPerfectSquare - * */ public function testPerfectSquare($input) { @@ -24,7 +24,6 @@ class PerfectSquareTest extends \PHPUnit_Framework_TestCase /** * @dataProvider providerForNotPerfectSquare * @expectedException Respect\Validation\Exceptions\PerfectSquareException - * */ public function testNotPerfectSquare($input) { @@ -64,4 +63,3 @@ class PerfectSquareTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/PhoneTest.php b/tests/Rules/PhoneTest.php index 3312c9ed..32045dde 100755 --- a/tests/Rules/PhoneTest.php +++ b/tests/Rules/PhoneTest.php @@ -1,4 +1,5 @@ phoneValidator = new Phone; + $this->phoneValidator = new Phone(); } /** * @dataProvider providerForPhone - * */ public function testValidPhoneShouldReturnTrue($input) { @@ -113,4 +113,3 @@ class PhoneTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/PositiveTest.php b/tests/Rules/PositiveTest.php index e2d0b4b8..4c9155bf 100644 --- a/tests/Rules/PositiveTest.php +++ b/tests/Rules/PositiveTest.php @@ -1,4 +1,5 @@ object = new Positive; + $this->object = new Positive(); } /** * @dataProvider providerForPositive - * */ public function testPositive($input) { @@ -57,4 +57,3 @@ class PositiveTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/PostalCodeTest.php b/tests/Rules/PostalCodeTest.php index 5d5b55ca..dcf3f21d 100644 --- a/tests/Rules/PostalCodeTest.php +++ b/tests/Rules/PostalCodeTest.php @@ -1,4 +1,5 @@ object = new PrimeNumber; + $this->object = new PrimeNumber(); } /** * @dataProvider providerForPrimeNumber - * */ public function testPrimeNumber($input) { @@ -24,7 +24,6 @@ class PrimeNumberTest extends \PHPUnit_Framework_TestCase /** * @dataProvider providerForNotPrimeNumber * @expectedException Respect\Validation\Exceptions\PrimeNumberException - * */ public function testNotPrimeNumber($input) { @@ -63,4 +62,3 @@ class PrimeNumberTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/PrntTest.php b/tests/Rules/PrntTest.php index 5226850f..7acbbe71 100644 --- a/tests/Rules/PrntTest.php +++ b/tests/Rules/PrntTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validPrint)); @@ -16,7 +17,7 @@ class PrntTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidPrint * @expectedException Respect\Validation\Exceptions\PrntException */ - public function testInvalidPrintShouldFailAndThrowPrntException($invalidPrint, $additional='') + public function testInvalidPrintShouldFailAndThrowPrntException($invalidPrint, $additional = '') { $validator = new Prnt($additional); $this->assertFalse($validator->validate($invalidPrint)); @@ -52,9 +53,9 @@ class PrntTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -76,9 +77,8 @@ class PrntTest extends \PHPUnit_Framework_TestCase { return array( array(null), - array("foo" . chr(7) . "bar"), - array("foo" . chr(10) . "bar"), + array('foo'.chr(7).'bar'), + array('foo'.chr(10).'bar'), ); } } - diff --git a/tests/Rules/PunctTest.php b/tests/Rules/PunctTest.php index ff2d8ed2..6032ec4f 100644 --- a/tests/Rules/PunctTest.php +++ b/tests/Rules/PunctTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validPunct)); @@ -16,7 +17,7 @@ class PunctTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidPunct * @expectedException Respect\Validation\Exceptions\PunctException */ - public function testInvalidPunctShouldFailAndThrowPunctException($invalidPunct, $additional='') + public function testInvalidPunctShouldFailAndThrowPunctException($invalidPunct, $additional = '') { $validator = new Punct($additional); $this->assertFalse($validator->validate($invalidPunct)); @@ -52,9 +53,9 @@ class PunctTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -83,4 +84,3 @@ class PunctTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/ReadableTest.php b/tests/Rules/ReadableTest.php index fcbd3746..3137e73e 100644 --- a/tests/Rules/ReadableTest.php +++ b/tests/Rules/ReadableTest.php @@ -8,7 +8,7 @@ function is_readable($readable) { $return = \is_readable($readable); // Running the real function if (null !== $GLOBALS['is_readable']) { - $return = $GLOBALS['is_readable']; + $return = $GLOBALS['is_readable']; $GLOBALS['is_readable'] = null; } @@ -17,7 +17,6 @@ function is_readable($readable) class ReadableTest extends \PHPUnit_Framework_TestCase { - /** * @covers Respect\Validation\Rules\Readable::validate */ @@ -55,5 +54,4 @@ class ReadableTest extends \PHPUnit_Framework_TestCase $this->assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/RegexTest.php b/tests/Rules/RegexTest.php index aa06cd45..05554bec 100644 --- a/tests/Rules/RegexTest.php +++ b/tests/Rules/RegexTest.php @@ -1,4 +1,5 @@ assertFalse($v->assert('w poiur')); } } - diff --git a/tests/Rules/RomanTest.php b/tests/Rules/RomanTest.php index c3a4eba1..44bb6604 100644 --- a/tests/Rules/RomanTest.php +++ b/tests/Rules/RomanTest.php @@ -1,4 +1,5 @@ romanValidator = new Roman; + $this->romanValidator = new Roman(); } /** * @dataProvider providerForRoman - * */ public function testValidRomansShouldReturnTrue($input) { @@ -63,4 +63,3 @@ class RomanTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/SfTest.php b/tests/Rules/SfTest.php index c5dfb749..1e8bf7bc 100644 --- a/tests/Rules/SfTest.php +++ b/tests/Rules/SfTest.php @@ -49,6 +49,7 @@ class SfTest extends \PHPUnit_Framework_TestCase \-These rules must pass for "34:90:70" \-Time EOF; + return $this->assertEquals( $expectedValidationException, $fullValidationMessage, diff --git a/tests/Rules/SlugTest.php b/tests/Rules/SlugTest.php index 292df126..46b33a32 100644 --- a/tests/Rules/SlugTest.php +++ b/tests/Rules/SlugTest.php @@ -1,4 +1,5 @@ slug = new Slug; + $this->slug = new Slug(); } /** @@ -37,7 +38,7 @@ class SlugTest extends \PHPUnit_Framework_TestCase array('o-rato-roeu-o-rei-de-roma'), array('o-alganet-e-um-feio'), array('a-e-i-o-u'), - array('anticonstitucionalissimamente') + array('anticonstitucionalissimamente'), ); } @@ -52,8 +53,7 @@ class SlugTest extends \PHPUnit_Framework_TestCase array('--nem-assim'), array('Nem mesmo Assim'), array('Ou-ate-assim'), - array('-Se juntar-tudo-Então-') + array('-Se juntar-tudo-Então-'), ); } } - diff --git a/tests/Rules/SpaceTest.php b/tests/Rules/SpaceTest.php index 7d8464f0..27f78426 100644 --- a/tests/Rules/SpaceTest.php +++ b/tests/Rules/SpaceTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validSpace)); @@ -16,7 +17,7 @@ class SpaceTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidSpace * @expectedException Respect\Validation\Exceptions\SpaceException */ - public function testInvalidSpaceShouldFailAndThrowSpaceException($invalidSpace, $additional='') + public function testInvalidSpaceShouldFailAndThrowSpaceException($invalidSpace, $additional = '') { $validator = new Space($additional); $this->assertFalse($validator->validate($invalidSpace)); @@ -52,9 +53,9 @@ class SpaceTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -63,10 +64,10 @@ class SpaceTest extends \PHPUnit_Framework_TestCase return array( array(''), array("\n"), - array(" "), - array(" "), + array(' '), + array(' '), array("\t"), - array(" "), + array(' '), ); } @@ -83,4 +84,3 @@ class SpaceTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/StartsWithTest.php b/tests/Rules/StartsWithTest.php index 7b375211..5cf5f49a 100644 --- a/tests/Rules/StartsWithTest.php +++ b/tests/Rules/StartsWithTest.php @@ -1,11 +1,11 @@ assertFalse($v->__invoke($input)); @@ -52,4 +52,3 @@ class StartsWithTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/StringTest.php b/tests/Rules/StringTest.php index b27f3218..62920898 100644 --- a/tests/Rules/StringTest.php +++ b/tests/Rules/StringTest.php @@ -1,4 +1,5 @@ object = new String; + $this->object = new String(); } /** * @dataProvider providerForString - * */ public function testString($input) { @@ -44,9 +44,8 @@ class StringTest extends \PHPUnit_Framework_TestCase return array( array(null), array(array()), - array(new \stdClass), - array(150) + array(new \stdClass()), + array(150), ); } } - diff --git a/tests/Rules/SymbolicLinkTest.php b/tests/Rules/SymbolicLinkTest.php index e89e2bfd..9c3cdff0 100644 --- a/tests/Rules/SymbolicLinkTest.php +++ b/tests/Rules/SymbolicLinkTest.php @@ -8,7 +8,7 @@ function is_link($link) { $return = \is_link($link); if (null !== $GLOBALS['is_link']) { - $return = $GLOBALS['is_link']; + $return = $GLOBALS['is_link']; $GLOBALS['is_link'] = null; } @@ -17,7 +17,6 @@ function is_link($link) class SymbolicLinkTest extends \PHPUnit_Framework_TestCase { - /** * @covers Respect\Validation\Rules\SymbolicLink::validate */ @@ -55,5 +54,4 @@ class SymbolicLinkTest extends \PHPUnit_Framework_TestCase $this->assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/TrueTest.php b/tests/Rules/TrueTest.php index 6070772c..c12bf925 100644 --- a/tests/Rules/TrueTest.php +++ b/tests/Rules/TrueTest.php @@ -1,4 +1,5 @@ assertSame($type, $rule->type); } public function testShouldNotBeCaseSensitive() { - $rule = new Type('InTeGeR'); + $rule = new Type('InTeGeR'); $this->assertTrue($rule->validate(42)); } diff --git a/tests/Rules/UploadedTest.php b/tests/Rules/UploadedTest.php index dff26b5c..1aa001b2 100644 --- a/tests/Rules/UploadedTest.php +++ b/tests/Rules/UploadedTest.php @@ -8,8 +8,8 @@ function is_uploaded_file($uploaded) { $return = \is_uploaded_file($uploaded); // Running the real function if (null !== $GLOBALS['is_uploaded_file']) { - $return = $GLOBALS['is_uploaded_file']; - $GLOBALS['is_uploaded_file'] = null; + $return = $GLOBALS['is_uploaded_file']; + $GLOBALS['is_uploaded_file'] = null; } return $return; @@ -17,7 +17,6 @@ function is_uploaded_file($uploaded) class UploadedTest extends \PHPUnit_Framework_TestCase { - /** * @covers Respect\Validation\Rules\Uploaded::validate */ @@ -54,5 +53,4 @@ class UploadedTest extends \PHPUnit_Framework_TestCase $this->assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/UppercaseTest.php b/tests/Rules/UppercaseTest.php index 97ec39b8..e28eeb66 100644 --- a/tests/Rules/UppercaseTest.php +++ b/tests/Rules/UppercaseTest.php @@ -1,4 +1,5 @@ assertTrue($validator->validate($validVowels)); @@ -16,7 +17,7 @@ class VowelTest extends \PHPUnit_Framework_TestCase * @dataProvider providerForInvalidVowels * @expectedException Respect\Validation\Exceptions\VowelException */ - public function testInvalidVowelsShouldFailAndThrowVowelException($invalidVowels, $additional='') + public function testInvalidVowelsShouldFailAndThrowVowelException($invalidVowels, $additional = '') { $validator = new Vowel($additional); $this->assertFalse($validator->validate($invalidVowels)); @@ -52,9 +53,9 @@ class VowelTest extends \PHPUnit_Framework_TestCase public function providerForInvalidParams() { return array( - array(new \stdClass), + array(new \stdClass()), array(array()), - array(0x2) + array(0x2), ); } @@ -87,4 +88,3 @@ class VowelTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/WhenTest.php b/tests/Rules/WhenTest.php index 4fc90aac..6a2a658e 100644 --- a/tests/Rules/WhenTest.php +++ b/tests/Rules/WhenTest.php @@ -1,4 +1,5 @@ assertTrue($v->validate(3)); $this->assertTrue($v->validate('aaa')); } public function testWhenError() { - $v = new When(new Int(), new Between(1,5), new NotEmpty()); + $v = new When(new Int(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->validate(15)); } public function testWhenWithoutElseHappypath() { - $v = new When(new Int(), new Between(1,5)); + $v = new When(new Int(), new Between(1, 5)); $this->assertTrue($v->validate(3)); } public function testWhenWithoutElseError() { - $v = new When(new String(), new Between(1,5)); + $v = new When(new String(), new Between(1, 5)); $this->assertFalse($v->validate(15)); } @@ -39,7 +40,7 @@ class WhenTest extends \PHPUnit_Framework_TestCase */ public function testWhenWithoutElseAssert() { - $v = new When(new String(), new Between(1,5)); + $v = new When(new String(), new Between(1, 5)); $v->assert(15); } @@ -48,7 +49,7 @@ class WhenTest extends \PHPUnit_Framework_TestCase */ public function testWhenException() { - $v = new When(new Int(), new Between(1,5), new NotEmpty()); + $v = new When(new Int(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->assert(15)); } @@ -57,7 +58,7 @@ class WhenTest extends \PHPUnit_Framework_TestCase */ public function testWhenException_on_else() { - $v = new When(new Int(), new Between(1,5), new NotEmpty()); + $v = new When(new Int(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->assert('')); } @@ -66,7 +67,7 @@ class WhenTest extends \PHPUnit_Framework_TestCase */ public function testWhenException_failfast() { - $v = new When(new Int(), new Between(1,5), new NotEmpty()); + $v = new When(new Int(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->check(15)); } @@ -75,8 +76,7 @@ class WhenTest extends \PHPUnit_Framework_TestCase */ public function testWhenException_on_else_failfast() { - $v = new When(new Int(), new Between(1,5), new NotEmpty()); + $v = new When(new Int(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->check('')); } } - diff --git a/tests/Rules/WritableTest.php b/tests/Rules/WritableTest.php index 341cb046..803df282 100644 --- a/tests/Rules/WritableTest.php +++ b/tests/Rules/WritableTest.php @@ -8,7 +8,7 @@ function is_writable($writable) { $return = \is_writable($writable); // Running the real function if (null !== $GLOBALS['is_writable']) { - $return = $GLOBALS['is_writable']; + $return = $GLOBALS['is_writable']; $GLOBALS['is_writable'] = null; } @@ -17,7 +17,6 @@ function is_writable($writable) class WritableTest extends \PHPUnit_Framework_TestCase { - /** * @covers Respect\Validation\Rules\Writable::validate */ @@ -55,5 +54,4 @@ class WritableTest extends \PHPUnit_Framework_TestCase $this->assertTrue($rule->validate($object)); } - } diff --git a/tests/Rules/XdigitTest.php b/tests/Rules/XdigitTest.php index 52df4936..9d9fad95 100644 --- a/tests/Rules/XdigitTest.php +++ b/tests/Rules/XdigitTest.php @@ -1,4 +1,5 @@ xdigitsValidator = new Xdigit; + $this->xdigitsValidator = new Xdigit(); } /** @@ -70,4 +71,3 @@ class XdigitTest extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/Rules/YesTest.php b/tests/Rules/YesTest.php index cf5834c8..af081d82 100644 --- a/tests/Rules/YesTest.php +++ b/tests/Rules/YesTest.php @@ -1,4 +1,5 @@ assertAttributeInstanceOf( $instanceOf = 'Zend\Validator\ValidatorInterface', - $attribute = 'zendValidator', - $instance = $v + $attribute = 'zendValidator', + $instance = $v ); } @@ -23,19 +24,19 @@ class ZendTest extends \PHPUnit_Framework_TestCase $v = new Zend('Zend\Validator\Date'); $this->assertAttributeInstanceOf( $instanceOf = 'Zend\Validator\ValidatorInterface', - $attribute = 'zendValidator', - $instance = $v + $attribute = 'zendValidator', + $instance = $v ); } public function testConstructorWithZendValidatorInstance() { - $zendInstance = new \Zend\Validator\Date; - $v = new Zend($zendInstance); + $zendInstance = new \Zend\Validator\Date(); + $v = new Zend($zendInstance); $this->assertAttributeSame( - $expected = $zendInstance, - $attribute = 'zendValidator', - $instance = $v + $expected = $zendInstance, + $attribute = 'zendValidator', + $instance = $v ); } @@ -44,11 +45,11 @@ class ZendTest extends \PHPUnit_Framework_TestCase */ public function testUserlandValidatorExtendingZendInterface() { - $v = new Zend(new MyValidator); + $v = new Zend(new MyValidator()); $this->assertAttributeInstanceOf( $instanceOf = 'Zend\Validator\ValidatorInterface', - $attribute = 'zendValidator', - $instance = $v + $attribute = 'zendValidator', + $instance = $v ); } @@ -57,8 +58,8 @@ class ZendTest extends \PHPUnit_Framework_TestCase $v = new Zend('Sitemap\Lastmod'); $this->assertAttributeInstanceOf( $instanceOf = 'Zend\Validator\ValidatorInterface', - $attribute = 'zendValidator', - $instance = $v + $attribute = 'zendValidator', + $instance = $v ); } @@ -68,7 +69,7 @@ class ZendTest extends \PHPUnit_Framework_TestCase */ public function testConstructorWithValidatorName_and_params() { - $zendValidatorName = 'StringLength'; + $zendValidatorName = 'StringLength'; $zendValidatorParams = array('min' => 10, 'max' => 25); $v = new Zend($zendValidatorName, $zendValidatorParams); $this->assertTrue( @@ -82,8 +83,8 @@ class ZendTest extends \PHPUnit_Framework_TestCase */ public function testZendDateValidatorWithRespectMethods() { - $v = new Zend('Date'); - $date = new DateTime; + $v = new Zend('Date'); + $date = new DateTime(); $this->assertTrue($v->validate($date)); $this->assertTrue($v->assert($date)); } @@ -125,4 +126,3 @@ if (class_exists('\Zend\Validator\Date')) { { } } - diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 219c4e09..832c17ed 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -1,4 +1,5 @@ between(1,2)->setTemplate('{{name}} is not tasty')->assert('something'); + Validator::callback('is_int')->between(1, 2)->setTemplate('{{name}} is not tasty')->assert('something'); } catch (NestedValidationExceptionInterface $e) { $this->assertEquals('"something" is not tasty', $e->getMainMessage()); } @@ -35,7 +36,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testSetTemplateWithMultipleValidatorsShouldUseTemplateAsFullMessage() { try { - Validator::callback('is_string')->between(1,2)->setTemplate('{{name}} is not tasty')->assert('something'); + Validator::callback('is_string')->between(1, 2)->setTemplate('{{name}} is not tasty')->assert('something'); } catch (NestedValidationExceptionInterface $e) { $this->assertEquals('\-"something" is not tasty \-"something" must be greater than 1', $e->getFullMessage()); @@ -44,7 +45,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testGetFullMessageShouldIncludeAllValidationMessagesInAChain() { try { - Validator::string()->length(1,15)->assert(''); + Validator::string()->length(1, 15)->assert(''); } catch (NestedValidationExceptionInterface $e) { $this->assertEquals('\-These rules must pass for "" \-"" must have a length between 1 and 15', $e->getFullMessage()); @@ -70,7 +71,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testIssue85FindMessagesShouldNotTriggerCatchableFatalError() { - $usernameValidator = Validator::alnum('_')->length(1,15)->noWhitespace(); + $usernameValidator = Validator::alnum('_')->length(1, 15)->noWhitespace(); try { $usernameValidator->assert('really messed up screen#name'); } catch (NestedValidationExceptionInterface $e) { @@ -81,9 +82,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testKeysAsValidatorNames() { try { - Validator::key('username', Validator::length(1,32)) + Validator::key('username', Validator::length(1, 32)) ->key('birthdate', Validator::date()) - ->setName("User Subscription Form") + ->setName('User Subscription Form') ->assert(array('username' => '', 'birthdate' => '')); } catch (NestedValidationExceptionInterface $e) { $this->assertEquals('\-These rules must pass for User Subscription Form diff --git a/tests/library/LocaleTestCase.php b/tests/library/LocaleTestCase.php index 18c19633..f53ffacd 100644 --- a/tests/library/LocaleTestCase.php +++ b/tests/library/LocaleTestCase.php @@ -1,4 +1,5 @@