From 9b85df4601352704d32bcffc1cfd4a3e61453345 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Wed, 7 Oct 2015 11:46:57 -0300 Subject: [PATCH] Rename rule "Int" to "IntVal" --- CONTRIBUTING.md | 2 +- docs/AllOf.md | 4 ++-- docs/Between.md | 2 +- docs/Call.md | 4 ++-- docs/Callback.md | 2 +- docs/Even.md | 2 +- docs/Finite.md | 2 +- docs/Infinite.md | 2 +- docs/{Int.md => IntVal.md} | 8 +++---- docs/KeySet.md | 8 +++---- docs/Max.md | 6 ++--- docs/Min.md | 6 ++--- docs/Multiple.md | 2 +- docs/NoneOf.md | 2 +- docs/Not.md | 4 ++-- docs/NotEmpty.md | 2 +- docs/Numeric.md | 2 +- docs/Odd.md | 2 +- docs/OneOf.md | 6 ++--- docs/README.md | 2 +- docs/Type.md | 2 +- docs/VALIDATORS.md | 6 ++--- docs/When.md | 2 +- .../{IntException.php => IntValException.php} | 2 +- library/Rules/{Int.php => IntVal.php} | 2 +- library/Validator.php | 2 +- .../not_should_work_by_builder.phpt | 2 +- tests/integration/not_with_recursion.phpt | 2 +- .../AbstractGroupedExceptionTest.php | 2 +- .../AbstractNestedExceptionTest.php | 4 ++-- tests/unit/Rules/AllOfTest.php | 4 ++-- tests/unit/Rules/EachTest.php | 6 ++--- .../Rules/{IntTest.php => IntValTest.php} | 10 ++++----- tests/unit/Rules/NotTest.php | 22 +++++++++---------- tests/unit/Rules/WhenTest.php | 14 ++++++------ 35 files changed, 76 insertions(+), 76 deletions(-) rename docs/{Int.md => IntVal.md} (63%) rename library/Exceptions/{IntException.php => IntValException.php} (92%) rename library/Rules/{Int.php => IntVal.php} (92%) rename tests/unit/Rules/{IntTest.php => IntValTest.php} (84%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 018c90a6..2124abf1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ on IRC, or on Gitter if you feel that we forgot to respond. Please see the [project documentation](http://respect.github.io/Validation) before proceeding. You should also know about [PHP-FIG](http://www.php-fig.org)'s standards and basic unit testing, but we're sure you can learn that just by -looking at other rules. Pick the simple ones like `Int` to begin. +looking at other rules. Pick the simple ones like `IntVal` to begin. Before writing anything, make sure there is no validator that already does what you need. Also, it would be awesome if you diff --git a/docs/AllOf.md b/docs/AllOf.md index 0cb747e9..415a27dd 100644 --- a/docs/AllOf.md +++ b/docs/AllOf.md @@ -6,7 +6,7 @@ Will validate if all inner validators validates. ```php v::allOf( - v::int(), + v::intVal(), v::positive() )->validate(15); //true ``` @@ -16,7 +16,7 @@ its syntax allows you to set custom names for every node: ```php v::allOf( - v::int()->setName('Account Number'), + v::intVal()->setName('Account Number'), v::positive()->setName('Higher Than Zero') )->setName('Positive integer') ->validate(15); //true diff --git a/docs/Between.md b/docs/Between.md index c8a9d728..567d81e5 100644 --- a/docs/Between.md +++ b/docs/Between.md @@ -6,7 +6,7 @@ Validates ranges. Most simple example: ```php -v::int()->between(10, 20)->validate(15); //true +v::intVal()->between(10, 20)->validate(15); //true ``` The type as the first validator in a chain is a good practice, diff --git a/docs/Call.md b/docs/Call.md index 43a2284e..0a8506ab 100644 --- a/docs/Call.md +++ b/docs/Call.md @@ -41,8 +41,8 @@ v::call( It is possible to call methods and closures as the first parameter: ```php -v::call(array($myObj, 'methodName'), v::int())->validate($myInput); -v::call(function($input) {}, v::int())->validate($myInput); +v::call(array($myObj, 'methodName'), v::intVal())->validate($myInput); +v::call(function($input) {}, v::intVal())->validate($myInput); ``` *** diff --git a/docs/Callback.md b/docs/Callback.md index 8b62978b..b18b5c0a 100644 --- a/docs/Callback.md +++ b/docs/Callback.md @@ -9,7 +9,7 @@ to validate something: v::callback('is_int')->validate(10); //true ``` -(Please note that this is a sample, the `v::int()` validator is much better). +(Please note that this is a sample, the `v::intVal()` validator is much better). As in `v::call()`, you can pass a method or closure to it. diff --git a/docs/Even.md b/docs/Even.md index 0b97cd44..ca3c0bff 100644 --- a/docs/Even.md +++ b/docs/Even.md @@ -5,7 +5,7 @@ Validates an even number. ```php -v::int()->even()->validate(2); //true +v::intVal()->even()->validate(2); //true ``` Using `int()` before `even()` is a best practice. diff --git a/docs/Finite.md b/docs/Finite.md index 316ea225..b6b461a2 100644 --- a/docs/Finite.md +++ b/docs/Finite.md @@ -14,5 +14,5 @@ See also: * [Digit](Digit.md) * [Infinite](Infinite.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [Numeric](Numeric.md) diff --git a/docs/Infinite.md b/docs/Infinite.md index 327aee21..1edc98a8 100644 --- a/docs/Infinite.md +++ b/docs/Infinite.md @@ -13,5 +13,5 @@ See also: * [Digit](Digit.md) * [Finite](Finite.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [Numeric](Numeric.md) diff --git a/docs/Int.md b/docs/IntVal.md similarity index 63% rename from docs/Int.md rename to docs/IntVal.md index a703105d..77b10931 100644 --- a/docs/Int.md +++ b/docs/IntVal.md @@ -1,12 +1,12 @@ -# Int +# IntVal -- `v::int()` +- `v::intVal()` Validates if the input is an integer. ```php -v::int()->validate('10'); //true -v::int()->validate(10); //true +v::intVal()->validate('10'); //true +v::intVal()->validate(10); //true ``` *** diff --git a/docs/KeySet.md b/docs/KeySet.md index 8ef02fd9..cb3756a4 100644 --- a/docs/KeySet.md +++ b/docs/KeySet.md @@ -8,7 +8,7 @@ Validates a keys in a defined structure. $dict = array('foo' => 42); v::keySet( - v::key('foo', v::int()) + v::key('foo', v::intVal()) )->validate($dict); //true ``` @@ -17,7 +17,7 @@ Extra keys are not allowed: $dict = array('foo' => 42, 'bar' => 'String'); v::keySet( - v::key('foo', v::int()) + v::key('foo', v::intVal()) )->validate($dict); //false ``` @@ -26,7 +26,7 @@ Missing required keys are not allowed: $dict = array('foo' => 42, 'bar' => 'String'); v::keySet( - v::key('foo', v::int()), + v::key('foo', v::intVal()), v::key('bar', v::string()), v::key('baz', v::boolType()) )->validate($dict); //false @@ -37,7 +37,7 @@ Missing non-required keys are allowed: $dict = array('foo' => 42, 'bar' => 'String'); v::keySet( - v::key('foo', v::int()), + v::key('foo', v::intVal()), v::key('bar', v::string()), v::key('baz', v::boolType(), false) )->validate($dict); //true diff --git a/docs/Max.md b/docs/Max.md index 312cbd81..91b1ed1d 100644 --- a/docs/Max.md +++ b/docs/Max.md @@ -6,9 +6,9 @@ Validates if the input doesn't exceed the maximum value. ```php -v::int()->max(15)->validate(20); //false -v::int()->max(20)->validate(20); //false -v::int()->max(20, true)->validate(20); //true +v::intVal()->max(15)->validate(20); //false +v::intVal()->max(20)->validate(20); //false +v::intVal()->max(20, true)->validate(20); //true ``` Also accepts dates: diff --git a/docs/Min.md b/docs/Min.md index e502b9a0..772bf38d 100644 --- a/docs/Min.md +++ b/docs/Min.md @@ -6,9 +6,9 @@ Validates if the input is greater than the minimum value. ```php -v::int()->min(15)->validate(5); //false -v::int()->min(5)->validate(5); //false -v::int()->min(5, true)->validate(5); //true +v::intVal()->min(15)->validate(5); //false +v::intVal()->min(5)->validate(5); //false +v::intVal()->min(5, true)->validate(5); //true ``` Also accepts dates: diff --git a/docs/Multiple.md b/docs/Multiple.md index ddc744fc..841d5bec 100644 --- a/docs/Multiple.md +++ b/docs/Multiple.md @@ -5,7 +5,7 @@ Validates if the input is a multiple of the given parameter ```php -v::int()->multiple(3)->validate(9); //true +v::intVal()->multiple(3)->validate(9); //true ``` *** diff --git a/docs/NoneOf.md b/docs/NoneOf.md index d88dcd61..b347ba0d 100644 --- a/docs/NoneOf.md +++ b/docs/NoneOf.md @@ -6,7 +6,7 @@ Validates if NONE of the given validators validate: ```php v::noneOf( - v::int(), + v::intVal(), v::floatVal() )->validate('foo'); //true ``` diff --git a/docs/Not.md b/docs/Not.md index 56ffa3c8..9cb50a78 100644 --- a/docs/Not.md +++ b/docs/Not.md @@ -19,13 +19,13 @@ In the sample above, validator returns true because 'foo' isn't an IP Address. You can negate complex, grouped or chained validators as well: ```php -v::not(v::int()->positive())->validate(-1.5); //true +v::not(v::intVal()->positive())->validate(-1.5); //true ``` using a shortcut ```php -v::int()->positive()->not()->validate(-1.5); //true +v::intVal()->positive()->not()->validate(-1.5); //true ``` Each other validation has custom messages for negated rules. diff --git a/docs/NotEmpty.md b/docs/NotEmpty.md index 3dc7ddbd..2f242648 100644 --- a/docs/NotEmpty.md +++ b/docs/NotEmpty.md @@ -19,7 +19,7 @@ v::notEmpty()->validate(null); //false Numbers: ```php -v::int()->notEmpty()->validate(0); //false +v::intVal()->notEmpty()->validate(0); //false ``` Empty arrays: diff --git a/docs/Numeric.md b/docs/Numeric.md index 740f1963..4e17747b 100644 --- a/docs/Numeric.md +++ b/docs/Numeric.md @@ -15,4 +15,4 @@ See also: * [Digit](Digit.md) * [Finite](Finite.md) * [Infinite](Infinite.md) - * [Int](Int.md) + * [IntVal](IntVal.md) diff --git a/docs/Odd.md b/docs/Odd.md index 5d432f95..b4870381 100644 --- a/docs/Odd.md +++ b/docs/Odd.md @@ -5,7 +5,7 @@ Validates an odd number. ```php -v::int()->odd()->validate(3); //true +v::intVal()->odd()->validate(3); //true ``` Using `int()` before `odd()` is a best practice. diff --git a/docs/OneOf.md b/docs/OneOf.md index a8f6d7a8..4878104e 100644 --- a/docs/OneOf.md +++ b/docs/OneOf.md @@ -6,12 +6,12 @@ This is a group validator that acts as an OR operator. ```php v::oneOf( - v::int(), + v::intVal(), v::floatVal() )->validate(15.5); //true ``` -In the sample above, `v::int()` doesn't validates, but +In the sample above, `v::intVal()` doesn't validates, but `v::floatVal()` validates, so oneOf returns true. `v::oneOf` returns true if at least one inner validator @@ -20,7 +20,7 @@ passes. Using a shortcut ```php -v::int()->addOr(v::floatVal())->validate(15.5); //true +v::intVal()->addOr(v::floatVal())->validate(15.5); //true ``` *** diff --git a/docs/README.md b/docs/README.md index b9d712ea..ea420a26 100644 --- a/docs/README.md +++ b/docs/README.md @@ -81,7 +81,7 @@ See more on [Optional](Optional.md). You can use the `v::not()` to negate any rule: ```php -v::not(v::int())->validate(10); //false, input must not be integer +v::not(v::intVal())->validate(10); //false, input must not be integer ``` ## Validator Reuse diff --git a/docs/Type.md b/docs/Type.md index 479bddbd..36652039 100644 --- a/docs/Type.md +++ b/docs/Type.md @@ -20,7 +20,7 @@ See also: * [FloatVal](FloatVal.md) * [Infinite](Infinite.md) * [Instance](Instance.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [Object](Object.md) * [Resource](Resource.md) * [Scalar](Scalar.md) diff --git a/docs/VALIDATORS.md b/docs/VALIDATORS.md index 3a540c11..ca97bb57 100644 --- a/docs/VALIDATORS.md +++ b/docs/VALIDATORS.md @@ -9,7 +9,7 @@ * [FalseVal](FalseVal.md) * [FloatVal](FloatVal.md) * [Instance](Instance.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [NullValue](NullValue.md) * [Numeric](Numeric.md) * [Object](Object.md) @@ -49,7 +49,7 @@ * [Finite](Finite.md) * [FloatVal](FloatVal.md) * [Infinite](Infinite.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [Multiple](Multiple.md) * [Negative](Negative.md) * [NotEmpty](NotEmpty.md) @@ -224,7 +224,7 @@ * [In](In.md) * [Infinite](Infinite.md) * [Instance](Instance.md) - * [Int](Int.md) + * [IntVal](IntVal.md) * [Ip](Ip.md) * [Json](Json.md) * [Key](Key.md) diff --git a/docs/When.md b/docs/When.md index f1cab79a..6254cb34 100644 --- a/docs/When.md +++ b/docs/When.md @@ -9,7 +9,7 @@ When the `$if` validates, returns validation for `$then`. When the `$if` doesn't validate, returns validation for `$else`, if defined. ```php -v::when(v::int(), v::positive(), v::notEmpty())->validate($input); +v::when(v::intVal(), v::positive(), v::notEmpty())->validate($input); ``` In the sample above, if `$input` is an integer, then it must be positive. diff --git a/library/Exceptions/IntException.php b/library/Exceptions/IntValException.php similarity index 92% rename from library/Exceptions/IntException.php rename to library/Exceptions/IntValException.php index 6500d405..0def1d02 100644 --- a/library/Exceptions/IntException.php +++ b/library/Exceptions/IntValException.php @@ -11,7 +11,7 @@ namespace Respect\Validation\Exceptions; -class IntException extends ValidationException +class IntValException extends ValidationException { public static $defaultTemplates = array( self::MODE_DEFAULT => array( diff --git a/library/Rules/Int.php b/library/Rules/IntVal.php similarity index 92% rename from library/Rules/Int.php rename to library/Rules/IntVal.php index 204aba83..9da26c1b 100644 --- a/library/Rules/Int.php +++ b/library/Rules/IntVal.php @@ -11,7 +11,7 @@ namespace Respect\Validation\Rules; -class Int extends AbstractRule +class IntVal extends AbstractRule { public function validate($input) { diff --git a/library/Validator.php b/library/Validator.php index 30d57295..68615d10 100644 --- a/library/Validator.php +++ b/library/Validator.php @@ -66,7 +66,7 @@ use Respect\Validation\Rules\Key; * @method static Validator in(mixed $haystack, bool $compareIdentical = false) * @method static Validator infinite() * @method static Validator instance(string $instanceName) - * @method static Validator int() + * @method static Validator intVal() * @method static Validator ip(mixed $ipOptions = null) * @method static Validator json() * @method static Validator key(string $reference, Validatable $referenceValidator = null, bool $mandatory = true) diff --git a/tests/integration/not_should_work_by_builder.phpt b/tests/integration/not_should_work_by_builder.phpt index bc004400..649e06e0 100644 --- a/tests/integration/not_should_work_by_builder.phpt +++ b/tests/integration/not_should_work_by_builder.phpt @@ -6,7 +6,7 @@ require 'vendor/autoload.php'; use Respect\Validation\Validator; -var_dump(Validator::not(Validator::int())->validate(10)); +var_dump(Validator::not(Validator::intVal())->validate(10)); ?> --EXPECTF-- bool(false) diff --git a/tests/integration/not_with_recursion.phpt b/tests/integration/not_with_recursion.phpt index 7df8190f..f701bda1 100644 --- a/tests/integration/not_with_recursion.phpt +++ b/tests/integration/not_with_recursion.phpt @@ -13,7 +13,7 @@ try { Validator::not( Validator::not( Validator::not( - Validator::int()->positive() + Validator::intVal()->positive() ) ) ) diff --git a/tests/unit/Exceptions/AbstractGroupedExceptionTest.php b/tests/unit/Exceptions/AbstractGroupedExceptionTest.php index 29affb2c..4070481b 100644 --- a/tests/unit/Exceptions/AbstractGroupedExceptionTest.php +++ b/tests/unit/Exceptions/AbstractGroupedExceptionTest.php @@ -15,7 +15,7 @@ class AbstractGroupedExceptionTest extends \PHPUnit_Framework_TestCase { public function testOneOrMoreGroupedExceptionsShouldBeCondensedByGetRelated() { - $int = new IntException(); + $int = new IntValException(); $e = new AbstractGroupedException(); $e2 = new AbstractNestedException(); $e->addRelated($e2); diff --git a/tests/unit/Exceptions/AbstractNestedExceptionTest.php b/tests/unit/Exceptions/AbstractNestedExceptionTest.php index 6df279bc..fe58f268 100644 --- a/tests/unit/Exceptions/AbstractNestedExceptionTest.php +++ b/tests/unit/Exceptions/AbstractNestedExceptionTest.php @@ -31,7 +31,7 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase public function testGetRelatedShouldReturnExceptionAddedByAddRelated() { $composite = new AttributeException(); - $node = new IntException(); + $node = new IntValException(); $composite->addRelated($node); $this->assertEquals(1, count($composite->getRelated(true))); $this->assertContainsOnly($node, $composite->getRelated()); @@ -40,7 +40,7 @@ class AbstractNestedExceptionTest extends \PHPUnit_Framework_TestCase public function testAddingTheSameInstanceShouldAddJustASingleReference() { $composite = new AttributeException(); - $node = new IntException(); + $node = new IntValException(); $composite->addRelated($node); $composite->addRelated($node); $composite->addRelated($node); diff --git a/tests/unit/Rules/AllOfTest.php b/tests/unit/Rules/AllOfTest.php index 5bbedc07..b11ed467 100644 --- a/tests/unit/Rules/AllOfTest.php +++ b/tests/unit/Rules/AllOfTest.php @@ -20,7 +20,7 @@ class AllOfTest extends \PHPUnit_Framework_TestCase { public function testRemoveRulesShouldRemoveAllRules() { - $o = new AllOf(new Int(), new Positive()); + $o = new AllOf(new IntVal(), new Positive()); $o->removeRules(); $this->assertEquals(0, count($o->getRules())); } @@ -30,7 +30,7 @@ class AllOfTest extends \PHPUnit_Framework_TestCase $o = new AllOf(); $o->addRules( array( - array($x = new Int(), new Positive()), + array($x = new IntVal(), new Positive()), ) ); $this->assertTrue($o->hasRule($x)); diff --git a/tests/unit/Rules/EachTest.php b/tests/unit/Rules/EachTest.php index d33bbc25..ae427424 100644 --- a/tests/unit/Rules/EachTest.php +++ b/tests/unit/Rules/EachTest.php @@ -31,7 +31,7 @@ class EachTest extends \PHPUnit_Framework_TestCase public function testValidatorShouldPassIfEveryArrayItemAndKeyPass() { - $v = new Each(new Alpha(), new Int()); + $v = new Each(new Alpha(), new IntVal()); $result = $v->validate(array('a', 'b', 'c', 'd', 'e')); $this->assertTrue($result); $result = $v->check(array('a', 'b', 'c', 'd', 'e')); @@ -42,7 +42,7 @@ class EachTest extends \PHPUnit_Framework_TestCase public function testValidatorShouldPassWithOnlyKeyValidation() { - $v = new Each(null, new Int()); + $v = new Each(null, new IntVal()); $result = $v->validate(array('a', 'b', 'c', 'd', 'e')); $this->assertTrue($result); $result = $v->check(array('a', 'b', 'c', 'd', 'e')); @@ -80,7 +80,7 @@ class EachTest extends \PHPUnit_Framework_TestCase */ public function testAssertShouldFailOnInvalidItem() { - $v = new Each(new Int()); + $v = new Each(new IntVal()); $result = $v->assert(array('a', 2, 3, 4, 5)); $this->assertFalse($result); } diff --git a/tests/unit/Rules/IntTest.php b/tests/unit/Rules/IntValTest.php similarity index 84% rename from tests/unit/Rules/IntTest.php rename to tests/unit/Rules/IntValTest.php index b979834c..d3c9e84e 100644 --- a/tests/unit/Rules/IntTest.php +++ b/tests/unit/Rules/IntValTest.php @@ -13,16 +13,16 @@ namespace Respect\Validation\Rules; /** * @group rule - * @covers Respect\Validation\Rules\Int - * @covers Respect\Validation\Exceptions\IntException + * @covers Respect\Validation\Rules\IntVal + * @covers Respect\Validation\Exceptions\IntValException */ -class IntTest extends \PHPUnit_Framework_TestCase +class IntValTest extends \PHPUnit_Framework_TestCase { protected $intValidator; protected function setUp() { - $this->intValidator = new Int(); + $this->intValidator = new IntVal(); } /** @@ -37,7 +37,7 @@ class IntTest extends \PHPUnit_Framework_TestCase /** * @dataProvider providerForNotInt - * @expectedException Respect\Validation\Exceptions\IntException + * @expectedException Respect\Validation\Exceptions\IntValException */ public function testInvalidIntegersShouldThrowIntException($input) { diff --git a/tests/unit/Rules/NotTest.php b/tests/unit/Rules/NotTest.php index b5f5cfc8..e8f429f7 100644 --- a/tests/unit/Rules/NotTest.php +++ b/tests/unit/Rules/NotTest.php @@ -31,7 +31,7 @@ class NotTest extends \PHPUnit_Framework_TestCase public function testShortcutNot() { - $this->assertTrue(Validator::int()->not()->assert('afg')); + $this->assertTrue(Validator::intVal()->not()->assert('afg')); } /** @@ -49,30 +49,30 @@ class NotTest extends \PHPUnit_Framework_TestCase */ public function testShortcutNotNotHaha() { - $this->assertFalse(Validator::int()->not()->assert(10)); + $this->assertFalse(Validator::intVal()->not()->assert(10)); } public function providerForValidNot() { return array( - array(new Int(), ''), - array(new Int(), 'aaa'), + array(new IntVal(), ''), + array(new IntVal(), 'aaa'), array(new AllOf(new NoWhitespace(), new Digit()), 'as df'), array(new AllOf(new NoWhitespace(), new Digit()), '12 34'), array(new AllOf(new AllOf(new NoWhitespace(), new Digit())), '12 34'), - array(new AllOf(new NoneOf(new Numeric(), new Int())), 13.37), - array(new NoneOf(new Numeric(), new Int()), 13.37), - array(Validator::noneOf(Validator::numeric(), Validator::int()), 13.37), + array(new AllOf(new NoneOf(new Numeric(), new IntVal())), 13.37), + array(new NoneOf(new Numeric(), new IntVal()), 13.37), + array(Validator::noneOf(Validator::numeric(), Validator::intVal()), 13.37), ); } public function providerForInvalidNot() { return array( - array(new Int(), 123), - array(new AllOf(new OneOf(new Numeric(), new Int())), 13.37), - array(new OneOf(new Numeric(), new Int()), 13.37), - array(Validator::oneOf(Validator::numeric(), Validator::int()), 13.37), + array(new IntVal(), 123), + array(new AllOf(new OneOf(new Numeric(), new IntVal())), 13.37), + array(new OneOf(new Numeric(), new IntVal()), 13.37), + array(Validator::oneOf(Validator::numeric(), Validator::intVal()), 13.37), ); } } diff --git a/tests/unit/Rules/WhenTest.php b/tests/unit/Rules/WhenTest.php index 9b10bd86..487e9e5b 100644 --- a/tests/unit/Rules/WhenTest.php +++ b/tests/unit/Rules/WhenTest.php @@ -20,20 +20,20 @@ class WhenTest extends \PHPUnit_Framework_TestCase { public function testWhenHappypath() { - $v = new When(new Int(), new Between(1, 5), new NotEmpty()); + $v = new When(new IntVal(), new Between(1, 5), new NotEmpty()); $this->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 IntVal(), 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 IntVal(), new Between(1, 5)); $this->assertTrue($v->validate(3)); } @@ -60,7 +60,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 IntVal(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->assert(15)); } @@ -69,7 +69,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 IntVal(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->assert('')); } @@ -78,7 +78,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 IntVal(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->check(15)); } @@ -87,7 +87,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 IntVal(), new Between(1, 5), new NotEmpty()); $this->assertFalse($v->check('')); } }