44 lines
755 B
PHP
44 lines
755 B
PHP
|
<?php
|
||
|
|
||
|
class STRTest extends UnitTestCase {
|
||
|
|
||
|
private $obj;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
}
|
||
|
|
||
|
public function TestStrFunction()
|
||
|
{
|
||
|
$obj = new \PHPUtil\Str('');
|
||
|
$obj2 = str('');
|
||
|
|
||
|
$this->assertEqual($obj, $obj2);
|
||
|
}
|
||
|
|
||
|
public function Test__invoke()
|
||
|
{
|
||
|
$obj = str('');
|
||
|
$obj2 = $obj('');
|
||
|
|
||
|
$this->assertEqual($obj, $obj2);
|
||
|
}
|
||
|
|
||
|
public function TestReplace()
|
||
|
{
|
||
|
$str = str("test")->replace("tes", "a");
|
||
|
$str2 = str_replace("tes", "a", "test");
|
||
|
|
||
|
$this->assertEqual($str, $str2);
|
||
|
}
|
||
|
|
||
|
public function TestMultiReplace()
|
||
|
{
|
||
|
$str = str("test")->replace("tes", "a")->replace("at", "sam");
|
||
|
$str2 = str_replace("tes", "a", "test");
|
||
|
$str2 = str_replace("at", "sam", $str2);
|
||
|
|
||
|
$this->assertEqual($str, $str2);
|
||
|
}
|
||
|
}
|