PHPLib/tests/str.test.php

44 lines
755 B
PHP
Raw Normal View History

2013-01-31 15:24:10 -05:00
<?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);
}
}