Skip to content
Permalink
Browse files

Tests: added test for Strings::replace with invalid callback

  • Loading branch information
f3l1x authored and dg committed Mar 25, 2020
1 parent 7982551 commit dd7444c5e884ad7fca43aa4596fa61665e4c6613
Showing with 6 additions and 0 deletions.
  1. +6 −0 tests/Utils/Strings.replace().errors.callback.phpt
@@ -6,6 +6,7 @@

declare(strict_types=1);

use Nette\InvalidStateException;
use Nette\Utils\Strings;
use Tester\Assert;

@@ -25,3 +26,8 @@ Assert::same('HELLO', Strings::replace('hello', '#.+#', function ($m) {
preg_match('#\d#u', "0123456789\xFF"); // Malformed UTF-8 data
return strtoupper($m[0]);
}));


Assert::exception(function () {
Strings::replace('hello', '#.+#', [stdClass::class, 'foobar']);
}, InvalidStateException::class, "Callback 'stdClass::foobar' is not callable.");

0 comments on commit dd7444c

Please sign in to comment.
You can’t perform that action at this time.