Codeception: Can't assert table row with cyrillic symbols

Created on 12 Mar 2014  路  3Comments  路  Source: Codeception/Codeception

$I->seeInDatabase('user', array('first_name' => Users::$Ivan->firstname, 'last_name' => Users::$Ivan->lastname, 'email' => Users::$Ivan->login));
Failed to register a new user in LoginCest.RegisterNewUser_GetActivationLink
Sorry, I couldn't see in database "user",{"first_name":"袠胁邪薪","last_name":"袠胁邪薪芯胁","email":"[email protected]"}:
No matching records found
Failed asserting that '0' is greater than 0.

If I replace firstname and lastname with english values it will work.
Database has utf8 default collation, and test files saved in UTF-8.

Reproduce

Most helpful comment

I found a solution. in the connection string to the database you need to specify the encoding, which we use at work
dsn: 'mysql:host=localhost;dbname=myDbName;charset=utf8'

All 3 comments

I have a same problem

1) Failed to test cyrillic text in seeindatabase in CyrillicTestCept (/home/dvapelnik/WebProjects/olympia/www/qa/tests/acceptance/CyrillicTestCept.php)
Couldn't see in database "codecept_test",{"text_cyrillic":"褌械褋褌"}:
No matching records found
Failed asserting that '0' is greater than 0.

Scenario Steps:
2. I see in database "codecept_test",{"text_cyrillic":"褌械褋褌"}
1. I see in database "codecept_test",{"text_latin":"test"}
CREATE TABLE `olympia`.`codecept_test` (
  `text_latin` VARCHAR(45) NULL,
  `text_cyrillic` VARCHAR(45) NULL)
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;

insert into codecept_test (text_latin, text_cyrillic) values ('test', '褌械褋褌');
<?php 
$I = new WebGuy($scenario);
$I->wantTo('test cyrillic text in seeInDataBase');
$I->seeInDatabase('codecept_test', array(
    'text_latin' => 'test'
));
$I->seeInDatabase('codecept_test', array(
    'text_cyrillic' => '褌械褋褌'
));

first assertion was passed
second assertion was failed

$ php -v
PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep  4 2014 06:56:34) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
$ php codecept.phar --version
Codeception version 2.0.5

Sorry, but do you have any ideas?

I found a solution. in the connection string to the database you need to specify the encoding, which we use at work
dsn: 'mysql:host=localhost;dbname=myDbName;charset=utf8'

Was this page helpful?
0 / 5 - 0 ratings