From 611f2648851b3bf2e3f47c5a89f69208be7af0c9 Mon Sep 17 00:00:00 2001 From: Marcos Neves Date: Fri, 16 Aug 2013 22:34:44 -0300 Subject: [PATCH] Add a BaseTest class to reset static properties on setUp and tearDown --- phpunit.xml | 2 +- tests/Valitron/BaseTestCase.php | 24 +++++++++++++++++++ tests/Valitron/ErrorMessages.php | 2 +- tests/Valitron/StaticLangTest.php | 17 +------------ .../{Validate.php => ValidateTest.php} | 2 +- tests/bootstrap.php | 1 + 6 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 tests/Valitron/BaseTestCase.php rename tests/Valitron/{Validate.php => ValidateTest.php} (99%) diff --git a/phpunit.xml b/phpunit.xml index 8e425f9..5693a09 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,7 +12,7 @@ > - tests/Valitron + tests/Valitron diff --git a/tests/Valitron/BaseTestCase.php b/tests/Valitron/BaseTestCase.php new file mode 100644 index 0000000..0dec6c4 --- /dev/null +++ b/tests/Valitron/BaseTestCase.php @@ -0,0 +1,24 @@ +tearDown(); + } + + public function tearDown() + { + $this->resetProperty('_lang'); + $this->resetProperty('_langDir'); + $this->resetProperty('_ruleMessages', array()); + } + + protected function resetProperty($name, $value = null) + { + $prop = new ReflectionProperty('Valitron\Validator', $name); + $prop->setAccessible(true); + $prop->setValue($value); + $prop->setAccessible(false); + } +} diff --git a/tests/Valitron/ErrorMessages.php b/tests/Valitron/ErrorMessages.php index b517e2f..51f7f19 100644 --- a/tests/Valitron/ErrorMessages.php +++ b/tests/Valitron/ErrorMessages.php @@ -1,7 +1,7 @@ resetProperty('_lang'); - $this->resetProperty('_langDir'); - $this->resetProperty('_ruleMessages', array()); - } - - protected function resetProperty($name, $value = null) - { - $prop = new ReflectionProperty('Valitron\Validator', $name); - $prop->setAccessible(true); - $prop->setValue($value); - $prop->setAccessible(false); - } - protected function getLangDir() { return __DIR__.'/../../lang'; diff --git a/tests/Valitron/Validate.php b/tests/Valitron/ValidateTest.php similarity index 99% rename from tests/Valitron/Validate.php rename to tests/Valitron/ValidateTest.php index 8f61764..b3d5d1b 100644 --- a/tests/Valitron/Validate.php +++ b/tests/Valitron/ValidateTest.php @@ -1,7 +1,7 @@