Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KorsaR-ZN committed Jul 1, 2015
1 parent 39a0fc1 commit c43f476
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/PhalconTest/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
65 changes: 65 additions & 0 deletions tests/unit/Phalcon/Text/TextDynamicTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* TextDynamicTest.php
* \Phalcon\Text\TextDynamicTest
*
* Tests the Phalcon\Text component
*
* Phalcon Framework
*
* @copyright (c) 2011-2015 Phalcon Team
* @link http://www.phalconphp.com
* @author Andres Gutierrez <andres@phalconphp.com>
* @author Nikolaos Dimopoulos <nikos@phalconphp.com>
*
* 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 <korsar.zn@gmail.com>
* @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,');
}

}
);
}
}

0 comments on commit c43f476

Please sign in to comment.