diff --git a/tests/PhalconTest/Text.php b/tests/PhalconTest/Text.php index 9f05b59b318..da2abb6bb64 100644 --- a/tests/PhalconTest/Text.php +++ b/tests/PhalconTest/Text.php @@ -75,4 +75,10 @@ public static function concat($separator, $a, $b) { return call_user_func_array('parent::concat', func_get_args()); } + + public static function dynamic($text, $leftDelimiter = '{', $rightDelimiter = '}', $separator = '|') + { + return parent::dynamic($text, $leftDelimiter, $rightDelimiter, $separator); + } + } diff --git a/tests/unit/Phalcon/Text/TextDynamicTest.php b/tests/unit/Phalcon/Text/TextDynamicTest.php new file mode 100644 index 00000000000..c6dbdf4204a --- /dev/null +++ b/tests/unit/Phalcon/Text/TextDynamicTest.php @@ -0,0 +1,65 @@ + + * @author Nikolaos Dimopoulos + * + * The contents of this file are subject to the New BSD License that is + * bundled with this package in the file docs/LICENSE.txt + * + * If you did not receive a copy of the license and are unable to obtain it + * through the world-wide-web, please send an email to license@phalconphp.com + * so that we can send you a copy immediately. + */ +namespace Phalcon\Tests\unit\Phalcon\Text; + + +use \PhalconTest\Text as PhTText; + + +class TextDynamicTest extends Helper\TextBase +{ + /** + * Tests the dynamic function + * + * @author Stanislav Kiryukhin + * @since 2015-07-01 + */ + public function testTextDynamicString() + { + $this->specify( + "dynamic do not return the correct string", + function () { + + // Test 1 + $actual = PhTText::dynamic('{Hi|Hello}, my name is a Bob!'); + expect($actual)->notContains('{'); + + try { + expect($actual)->contains('Hi,'); + } catch (\ErrorException $e) { + expect($actual)->contains('Hello,'); + } + + // Test 2 + $actual = PhTText::dynamic('(Hi|Hello), my name is a Bob!', '(', ')'); + expect($actual)->notContains('('); + + try { + expect($actual)->contains('Hi,'); + } catch (\ErrorException $e) { + expect($actual)->contains('Hello,'); + } + + } + ); + } +} \ No newline at end of file