diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-08-03 07:04:30 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-08-03 07:04:30 +0200 |
commit | 11c5be9916ee46690507cb004053a3773e699436 (patch) | |
tree | 566b4a3fe654f4d5a9b05943f0345309f389c79f /Test | |
parent | b03af96129159098c0b34b1950769f3f198dd9cd (diff) | |
download | Ustring-11c5be9916ee46690507cb004053a3773e699436.zip Ustring-11c5be9916ee46690507cb004053a3773e699436.tar.gz Ustring-11c5be9916ee46690507cb004053a3773e699436.tar.bz2 |
Test `ext/mbstring` availability globally.
First, in the constructor, we tested whether the `ext/mbstring`
extension was available or not. This check was made each time the
constructor run. This is useless and we can optimize it. Second, some
static methods were using `ext/mbstring`, so this check was not made and
this situation could lead to unexpected errors.
This patch introduces and testes the `checkMbString` static method. As
its name suggests, it checks whether the `ext/mbstring` extension is
available or not.
We finally use this method globally, after the class declaration, and
throw an exception if the extension is not available.
Diffstat (limited to 'Test')
-rw-r--r-- | Test/Unit/Ustring.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Test/Unit/Ustring.php b/Test/Unit/Ustring.php index 0443892..a03db3c 100644 --- a/Test/Unit/Ustring.php +++ b/Test/Unit/Ustring.php @@ -36,8 +36,8 @@ namespace Hoa\Ustring\Test\Unit; -use Hoa\Ustring as LUT; use Hoa\Test; +use Hoa\Ustring as LUT; /** * Class \Hoa\Ustring\Test\Unit\Ustring. @@ -49,7 +49,16 @@ use Hoa\Test; */ class Ustring extends Test\Unit\Suite { - public function case_no_mbstring() + public function case_check_mbstring() + { + $this + ->given($this->function->function_exists = true) + ->then + ->boolean(LUT::checkMbString()) + ->isTrue(); + } + + public function case_check_no_mbstring() { $this ->given( |