-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,'); | ||
} | ||
|
||
} | ||
); | ||
} | ||
} |