From 7e735e17ea87d280f032f9cf393b4d96837efc6f Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 14 Apr 2018 16:37:51 +0800 Subject: [PATCH 1/4] Test enhancement --- .travis.yml | 10 ++++++++-- composer.json | 14 +++++++++++--- phpunit.xml | 8 ++++++++ tests/bootstrap.php | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a941551..6f760ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,24 @@ # see http://about.travis-ci.org/docs/user/languages/php/ for more hints language: php -dist: precise # list any PHP version you want to test against php: - - 5.3 - 5.4 - 5.5 - 5.6 + - 7.0 + - 7.1 + - 7.2 + - nightly - hhvm matrix: allow_failures: - php: hhvm + - php: nightly + include: + - php: 5.3 + dist: precise before_script: - composer install diff --git a/composer.json b/composer.json index 066dda7..30e5c96 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,19 @@ "php": ">=5.3.2" }, "require-dev": { - "phpunit/phpunit": "~4.8.35" + "phpunit/phpunit": "^4.8.35 || ^5.5 || ^6.5" + }, + "suggest": { + "ext-mbstring": "It can support the multiple bytes string length." }, "autoload": { - "psr-0": { - "Valitron": "src/" + "psr-4": { + "Valitron\\": "src/Valitron" + } + }, + "autoload-dev": { + "psr-4": { + "Valitron\\": "tests/Valitron" } }, "scripts": { diff --git a/phpunit.xml b/phpunit.xml index 5693a09..f23518b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -15,4 +15,12 @@ tests/Valitron + + + src/ + + + vendor/ + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b4dcfb1..e33ce82 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -16,4 +16,4 @@ $loader = require __DIR__.'/../vendor/autoload.php'; } -require_once __DIR__ . '/Valitron/BaseTestCase.php'; \ No newline at end of file +require_once __DIR__ . '/Valitron/BaseTestCase.php'; From 631c8feb361ccc59f5423ee7244da80f6fe49966 Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 14 Apr 2018 16:44:21 +0800 Subject: [PATCH 2/4] Use composer test in Travis build script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6f760ee..18f183c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ before_script: - composer install # Script to run tests -script: ./vendor/bin/phpunit +script: composer test From 7c1175134d1347d53f9a784334d68a38da0210f0 Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 14 Apr 2018 16:48:59 +0800 Subject: [PATCH 3/4] Fix include setting space --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 18f183c..e2c0986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: allow_failures: - php: hhvm - php: nightly - include: + include: - php: 5.3 dist: precise From 9ec218f0318125e03af0a30accd2ad785847198b Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 14 Apr 2018 16:56:19 +0800 Subject: [PATCH 4/4] Fix count() countable error message in php7.2 --- tests/Valitron/ValidateTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index e25f7a2..4cf5b59 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -15,11 +15,11 @@ public function testOptionalFieldFilter() $this->assertEquals($v->data(), array('foo' => 'bar')); } - public function testAccurateErrorCount() + public function testAccurateErrorShouldReturnFalse() { $v = new Validator(array('name' => 'Chester Tester')); $v->rule('required', 'name'); - $this->assertSame(1, count($v->errors('name'))); + $this->assertFalse($v->errors('name')); } public function testArrayOfFieldsToValidate() {