Skip to content

Commit

Permalink
[+]: added tests for "strtonatfold()"
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Moelleken committed Feb 22, 2015
1 parent 7d3d73f commit 0e408fd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/UTF8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,19 @@ public function testStrnatcmp()
$this->assertEquals(1, UTF8::strnatcmp("Hello world 中文空白!", "Hello WORLD 中文空白!"));
}

public function testStrtonatfold()
{
$utf8 = new UTF8();

// valid utf-8
$string = $this->invokeMethod($utf8, 'strtonatfold', array("Hello world 中文空白"));
$this->assertEquals('Hello world 中文空白', $string);

// invalid utf-8
$string = $this->invokeMethod($utf8, 'strtonatfold', array("Iñtërnâtiôn\xE9àlizætiøn"));
$this->assertEquals('', $string);
}

public function testWordCount()
{
$testArray = array(
Expand Down Expand Up @@ -1348,4 +1361,22 @@ public function testChunkSplit()

$this->assertEquals($expected, $result);
}

/**
* Call protected/private method of a class.
*
* @param object &$object Instantiated object that we will run method on.
* @param string $methodName Method name to call
* @param array $parameters Array of parameters to pass into method.
*
* @return mixed Method return.
*/
public function invokeMethod(&$object, $methodName, array $parameters = array())
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);

return $method->invokeArgs($object, $parameters);
}
}

0 comments on commit 0e408fd

Please sign in to comment.