diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-08-03 07:06:46 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-08-03 07:06:46 +0200 |
commit | 9c6e7c84880c457a836fea4c9f4668ef766765dd (patch) | |
tree | 4ed882b6fd8a118aa7bdaa19d92d5a0735a3372f /Test | |
parent | 4cf922258a87eeb7edc592b45b21c6cf67b9bc5a (diff) | |
download | Ustring-9c6e7c84880c457a836fea4c9f4668ef766765dd.zip Ustring-9c6e7c84880c457a836fea4c9f4668ef766765dd.tar.gz Ustring-9c6e7c84880c457a836fea4c9f4668ef766765dd.tar.bz2 |
`ext/iconv` is suggested, no longer required.
First, this patch introduces and testes the `checkIconv` static method
that checks whether the `ext/iconv` extension is available or not.
Second, this method is used in the `Ustring::transcode` static method to
test whether this extension is available. If not, then an exception is
thrown.
Finally, because this is only for one method **and** to allow third
implementation to be used instead of the official `ext/iconv` extension,
this extension is now suggested instead of required in the
`composer.json` file. It removes one (strong) dependency to projects
using `hoa/ustring` if they are sure to not use
`Hoa\Ustring::transcode`.
Diffstat (limited to 'Test')
-rw-r--r-- | Test/Unit/Ustring.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Test/Unit/Ustring.php b/Test/Unit/Ustring.php index a03db3c..36095d4 100644 --- a/Test/Unit/Ustring.php +++ b/Test/Unit/Ustring.php @@ -901,6 +901,20 @@ class Ustring extends Test\Unit\Suite ->isEqualTo('11110000100111111001001010101001'); } + public function case_transcode_no_iconv() + { + $this + ->given( + $this->function->function_exists = function ($name) { + return 'iconv' !== $name; + } + ) + ->exception(function () { + LUT::transcode('foo', 'UTF-8'); + }) + ->isInstanceOf('Hoa\Ustring\Exception'); + } + public function case_transcode_and_isUtf8() { $this |