Codeception: seeInDatabase with special characters

Created on 18 Jul 2017  路  1Comment  路  Source: Codeception/Codeception

What are you trying to achieve?

see a record in the database with seeInDatabase()

What do you get instead?

no matchings found. the php file and the datebase collation are UTF-8

No matching records found for criteria {"triwala_wwentnahmestelle_id":23040,"triwala_id":"PNL01","triwala_wwanlage_id":2983,"triwala_mieter_id":null,"mieter_id":1,"strasse":"M\u00fcsterstra\u00dfe 3","stockwerk":"2. OG","wohnung":"rechts","zimmer":"Bad","genaue_entnahmestelle":"Waschbecken","art_ventil":"Einhebelmischer"} in table wwentnahmestellen
Failed asserting that 0 is greater than 0.
 C:\wamp64\www\XY\api\tests\_support\_generated\ApiTesterActions.php:4515
 C:\wamp64\www\XY\api\tests\api\LiegenschaftenCest.php:282

the problem is the name of the street M眉sterstra脽e 3 it gets converted to Mu00fcsterstrau00dfe 3 and of course this record is not stored in the DB

$I->seeInDatabase('wwentnahmestellen', [
            'triwala_wwentnahmestelle_id' => $pnl['id'],
            'triwala_id'                  => $pnl['triwala_id'],
            'triwala_wwanlage_id'         => $liegenschaft['wwanlage_id'],
            'triwala_mieter_id'           => null,
            'mieter_id'                   => 1,
            'strasse'                     => "M眉sterstra脽e 3",
            'stockwerk'                   => $pnl['stockwerk'],
            'wohnung'                     => $pnl['wohnung'],
            'zimmer'                      => $pnl['zimmer'],
            'genaue_entnahmestelle'       => $pnl['genaue_entnahmestelle'],
            'art_ventil'                  => $pnl['art_ventil'],
        ]);

Details

  • Codeception version: 2.3.4
  • PHP Version: 7.0.10
  • Operating System: Win10
  • Installation type: Composer
actor: ApiTester
modules:
    enabled:
        - \Helper\Api
        - Asserts
        - PhpBrowser:
            url: 'http://localhost/XY/api/api/'
            cookies:
              cookie-1:
                Name: 'XDEBUG_SESSION'
                Value: 'PHPSTORM'
        - REST:
            url: http://localhost/XY/api/api/
            depends: PhpBrowser
            part: Json
        - Filesystem
        - Db:
            dsn: 'mysql:host=localhost;dbname=tw_staging'
            user: 'root'
            password: ''
            dump: 'tests/_data/api_dump.sql'
            populate: true
            cleanup: true
            reconnect: true
Db

Most helpful comment

I had a similar problem today and found this old issue:

912

adding that to my Db module config inside codeception.yml solved it for me:
dsn: 'mysql:host=localhost;dbname=myDbName;charset=utf8'

>All comments

I had a similar problem today and found this old issue:

912

adding that to my Db module config inside codeception.yml solved it for me:
dsn: 'mysql:host=localhost;dbname=myDbName;charset=utf8'

Was this page helpful?
0 / 5 - 0 ratings