Testing Special Characters with the PHP Module

I am testing my controller from Symfony2 using PHPUnit and class WebTestCase

return self::$client->request(
    'POST', '/withdraw',
    array("amount" => 130),
    array(),array());

$this->assertEquals(
    "You can withdraw up to £100.00.",
     $crawler->filter("#error-notification")->text());

But I get this error:

Expected: "You can withdraw up to £100.00."
Actual:   "You can withdraw up to £100.00."

The fact is that everything looks fine on the web page and in the source code, so I think that PHPUnit may have some difficulty getting the text as UTF8?

What am I missing?

+4
source share
1 answer

Decision:

Make sure the extension is mbstringenabled.

An error was detected about unsuccessful tests iconvspecified in kohana bugtracker.


advice:

/ - UTF-8:

$this->assertEquals(
    mb_detect_encoding(
        crawler->filter("#error-notification")->text(),
        'UTF-8'
    ),
    'UTF-8'
);

accept-charset , :

$client->request(
    'POST', '/withdraw',
    array("amount" => 130),
    array(),
    array(),
    array('HTTP_ACCEPT_CHARSET' => 'utf-8')
);
+3

Source: https://habr.com/ru/post/1528767/


All Articles