From da91bdea708ee00f38c0579f2c88f578b1fc4e84 Mon Sep 17 00:00:00 2001 From: Willem Wollebrants Date: Wed, 7 Jul 2021 11:44:08 +0200 Subject: [PATCH 1/4] make tests compatible with phpunit for php8 --- .github/workflows/test.yml | 4 ++-- .gitignore | 1 + composer.json | 2 +- tests/Valitron/BaseTestCase.php | 5 ++--- tests/Valitron/LangTest.php | 9 ++++----- tests/Valitron/StaticVsInstanceTest.php | 1 + tests/Valitron/ValidateTest.php | 1 - 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5a4b05..b1c329e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,8 +17,8 @@ jobs: - '7.2' - '7.3' - '7.4' -# - '8.0' -# - '8.1' + - '8.0' + - '8.1' steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 17193f5..12d6107 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.phar composer.lock vendor .idea/ +.phpunit.result.cache \ No newline at end of file diff --git a/composer.json b/composer.json index c05eb0f..0937440 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.3.2" }, "require-dev": { - "phpunit/phpunit": ">=4.8.35 <8" + "phpunit/phpunit": ">=4.8.35 <9" }, "suggest": { "ext-mbstring": "It can support the multiple bytes string length." diff --git a/tests/Valitron/BaseTestCase.php b/tests/Valitron/BaseTestCase.php index 40cf559..5a0d42e 100644 --- a/tests/Valitron/BaseTestCase.php +++ b/tests/Valitron/BaseTestCase.php @@ -4,10 +4,8 @@ class BaseTestCase extends TestCase { - public function setUp() - { - } +/* public function tearDown() { $this->resetProperty('_lang'); @@ -23,4 +21,5 @@ protected function resetProperty($name, $value = null) $prop->setValue($value); $prop->setAccessible(false); } +*/ } diff --git a/tests/Valitron/LangTest.php b/tests/Valitron/LangTest.php index 7cd99c0..61bab65 100644 --- a/tests/Valitron/LangTest.php +++ b/tests/Valitron/LangTest.php @@ -15,8 +15,8 @@ public function testLangDefinedStatically() { $lang = 'ar'; Validator::lang($lang); - $validator = new Validator(array()); $this->assertEquals($lang, Validator::lang()); + Validator::lang('en'); } /** @@ -42,12 +42,11 @@ public function testDefaultLangDirShouldBePackageLangDir() $this->assertEquals(realpath($this->getLangDir()), realpath(Validator::langDir())); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Fail to load language file '/this/dir/does/not/exists/en.php' - */ + public function testLangException() { + $this->expectException("InvalidArgumentException"); + $this->expectExceptionMessage("Fail to load language file '/this/dir/does/not/exists/en.php'"); new Validator(array(), array(), 'en', '/this/dir/does/not/exists'); } diff --git a/tests/Valitron/StaticVsInstanceTest.php b/tests/Valitron/StaticVsInstanceTest.php index 174334c..44bf5c6 100644 --- a/tests/Valitron/StaticVsInstanceTest.php +++ b/tests/Valitron/StaticVsInstanceTest.php @@ -10,6 +10,7 @@ public function testInstanceOverrideStaticLang() $this->assertEquals( 'ar', Validator::lang(), 'instance defined lang should not replace static global lang' ); + Validator::lang('en'); } /** diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index de06b61..a7f7158 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -4,7 +4,6 @@ class ValidateTest extends BaseTestCase { - public function testValidWithNoRules() { $v = new Validator(array('name' => 'Chester Tester')); From 035eca309359e5682ec4f3a99eb203754dc77a76 Mon Sep 17 00:00:00 2001 From: Willem Wollebrants Date: Wed, 7 Jul 2021 11:47:59 +0200 Subject: [PATCH 2/4] make tests compatible with phpunit for php8 --- tests/Valitron/LangTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/Valitron/LangTest.php b/tests/Valitron/LangTest.php index 61bab65..f5447cb 100644 --- a/tests/Valitron/LangTest.php +++ b/tests/Valitron/LangTest.php @@ -45,9 +45,12 @@ public function testDefaultLangDirShouldBePackageLangDir() public function testLangException() { - $this->expectException("InvalidArgumentException"); - $this->expectExceptionMessage("Fail to load language file '/this/dir/does/not/exists/en.php'"); + try{ new Validator(array(), array(), 'en', '/this/dir/does/not/exists'); + } catch (Exception $exception){ + $this->assertInstanceOf("InvalidArgumentException", $exception); + $this->assertEquals("Fail to load language file '/this/dir/does/not/exists/en.php'", $exception->getMessage()); + } } From fe2ca630fbdbc6267f54f4971678c7bed017d101 Mon Sep 17 00:00:00 2001 From: Willem Wollebrants Date: Wed, 7 Jul 2021 11:52:59 +0200 Subject: [PATCH 3/4] make tests compatible with phpunit for php8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0937440..37c8712 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.3.2" }, "require-dev": { - "phpunit/phpunit": ">=4.8.35 <9" + "phpunit/phpunit": ">=4.8.35" }, "suggest": { "ext-mbstring": "It can support the multiple bytes string length." From f189549d2d422dd385ca1c80349d3903a7ebe0c0 Mon Sep 17 00:00:00 2001 From: Willem Wollebrants Date: Wed, 7 Jul 2021 11:55:52 +0200 Subject: [PATCH 4/4] make tests compatible with phpunit for php8 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1c329e..93e07ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: - '7.3' - '7.4' - '8.0' - - '8.1' + # - '8.1' steps: - name: Checkout uses: actions/checkout@v2