Im trying to assert a function in which mycode converts Windows-1252 code to UTF-8 Example as follows:
function test($article){
$result = mb_convert_encoding($article[0]['Description'], "UTF-8", "Windows-1252");
retrun $result;
}
I'm trying to input a Windows-1252 and assert its changes but its not working.
My Unititest:
$convertedArray = array(array('Description' => "an example pain— if you’re"));
$someString = $this->getMockBuilder('\Client')
->setMethods(['getArticle'])
->getMock();
$someString->expects($this->once())
->method('getArticle')
->with('12345')
->will($this->returnValue($convertedArray));
\client::set($someString);
Or
In simple: Im trying to input $str = "an example pain— if you’re"; and expect the function to convet it to UTF-8 and return "an example pain— if you’re" how can i do that?
Im getting the following error:
--- Expected
+++ Actual
@@ @@
Array (
- 'record' => 'an example pain— if you’re'
+ 'record' => 'an example pain� if you’re'
)
file_get_contents()and proceed with the unit test?file_get_contents()to be binary safe so it should work. If not, let me know and I'll search further :)