From f35c3763ae85a865380239c3339f856d7033f7f1 Mon Sep 17 00:00:00 2001 From: Konstantin Kuklin Date: Sat, 7 Apr 2018 08:26:54 +0300 Subject: [PATCH] fix validator --- .travis.yml | 6 ++++-- composer.json | 7 +++++-- src/Stream/Validator.php | 10 +++++----- tests/GetContentsTest.php | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ad9ef3..dfe82dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ language: php php: - - 5.3 - 5.4 - 5.5 - 5.6 + - 7.0 + - 7.1 + - 7.2 - hhvm before_script: @@ -15,4 +17,4 @@ after_script: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover -script: phpunit --coverage-clover=coverage.clover \ No newline at end of file +script: ./vendor/bin/phpunit --coverage-clover=coverage.clover diff --git a/composer.json b/composer.json index eb9b4b0..eb8a30a 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,12 @@ ], "require": { "php": ">=5.3.2", - "respect/validation": "*" + "respect/validation": "^1.1.15" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" }, "autoload": { "psr-0": {"Stream": "src/"} } -} \ No newline at end of file +} diff --git a/src/Stream/Validator.php b/src/Stream/Validator.php index 2c43e1c..3fbb450 100644 --- a/src/Stream/Validator.php +++ b/src/Stream/Validator.php @@ -46,9 +46,9 @@ public static function validateProtocol($protocol) */ public static function validatePort($port) { - if (!v::int()->between(0, 65635)->validate($port)) { + if (!v::intVal()->between(1, 65635)->validate($port)) { throw new PortValidateStreamException( - sprintf("Port '%s' is not a integer number or not inside the range: 0-65535", $port) + sprintf("Port '%s' is not a integer number or not inside the range: 1-65535", $port) ); } } @@ -72,7 +72,7 @@ public static function validatePath($path) */ public static function validateSeconds($seconds) { - if (!v::int()->min(0, true)->validate($seconds)) { + if (!v::intVal()->min(0, true)->validate($seconds)) { throw new StreamException( sprintf("Seconds must be int >= 0, got %s with value %s.", gettype($seconds), $seconds) ); @@ -86,10 +86,10 @@ public static function validateSeconds($seconds) */ public static function validateMicroSeconds($microSeconds) { - if ($microSeconds !== 0 && !v::int()->min(0, true)->validate($microSeconds)) { + if ($microSeconds !== 0 && !v::intVal()->min(0, true)->validate($microSeconds)) { throw new StreamException( sprintf("Micro seconds must be int >= 0, got %s with value %s.", gettype($microSeconds), $microSeconds) ); } } -} \ No newline at end of file +} diff --git a/tests/GetContentsTest.php b/tests/GetContentsTest.php index dd6d4b1..5ae042a 100644 --- a/tests/GetContentsTest.php +++ b/tests/GetContentsTest.php @@ -84,6 +84,6 @@ public function testGetContentsWork() $this->fail("Got wrong response."); } - $this->assertEquals("HTTP/1.0 302 Found", trim($contents[0]), "Contents was got incorrect."); + $this->assertEquals("HTTP/1.0 404 Not Found", trim($contents[0]), "Contents was got incorrect."); } -} \ No newline at end of file +}