Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JsonException] Malformed UTF-8 characters, possibly incorrectly encoded #47

Open
cybd opened this issue Mar 15, 2023 · 0 comments
Open

Comments

@cybd
Copy link
Contributor

cybd commented Mar 15, 2023

I'm using UUID as binary(16) in MySQL tables.
My test is failed when I'm trying to test seeInDatabase using UUID as filter criteria.

Test failed with error:
[JsonException] Malformed UTF-8 characters, possibly incorrectly encoded

php vendor/bin/codecept run unit Codeception/Module/Db/MySqlDbTest:testSeeInDatabaseWithBinary -vvv

Console output with -vvv mode:

Codeception PHP Testing Framework v5.0.10 https://helpukrainewin.org

  actor is empty

Unit Tests (1) --------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- MySqlDbTest: See in database with binary  [Connecting To Db] {"config":{"populate":true,"cleanup":true,"reconnect":true,"waitlock":0,"dump":"tests/data/dumps/mysql.sql","populator":null,"skip_cleanup_if_failed":false,"dsn":"mysql:host=host.docker.internal;port=3102;dbname=codeception","user":"root","password":"codeception"},"options":[]}
  [Db] Connected to default codeception
  [Db] Disconnected from default
  [Connecting To Db] {"config":{"populate":true,"cleanup":true,"reconnect":true,"waitlock":0,"dump":"tests/data/dumps/mysql.sql","populator":null,"skip_cleanup_if_failed":false,"dsn":"mysql:host=host.docker.internal;port=3102;dbname=codeception","user":"root","password":"codeception"},"options":[]}
  [Db] Connected to default codeception
  [Query] SELECT count(*) FROM `users` WHERE `uuid` = ? 
  [Parameters] ["u0011ufffdufffdKu0001ufffdrufffdufffdu001du0002Bufffdu0012u0000u0006"]
E MySqlDbTest: See in database with binary(0.19s)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 00:00.213, Memory: 12.00 MB

There was 1 error:
1) MySqlDbTest: See in database with binary
 Test  tests/unit/Codeception/Module/Db/MySqlDbTest.php:testSeeInDatabaseWithBinary
                                                                            
  [JsonException] Malformed UTF-8 characters, possibly incorrectly encoded  
                                                                            
/var/www/html/src/Codeception/Module/Db.php:839
/var/www/html/tests/unit/Codeception/Module/Db/AbstractDbTest.php:69
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:1067
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:634
/var/www/html/vendor/codeception/codeception/src/Codeception/Test/TestCaseWrapper.php:148
/var/www/html/vendor/codeception/codeception/src/Codeception/Test/Test.php:170
/var/www/html/vendor/codeception/codeception/src/Codeception/Suite.php:130
/var/www/html/vendor/codeception/codeception/src/Codeception/SuiteManager.php:148
/var/www/html/vendor/codeception/codeception/src/Codeception/Codecept.php:260
/var/www/html/vendor/codeception/codeception/src/Codeception/Codecept.php:216
/var/www/html/vendor/codeception/codeception/src/Codeception/Command/Run.php:435
/var/www/html/vendor/symfony/console/Command/Command.php:326
/var/www/html/vendor/symfony/console/Application.php:1063
/var/www/html/vendor/symfony/console/Application.php:320
/var/www/html/vendor/symfony/console/Application.php:174
/var/www/html/vendor/codeception/codeception/src/Codeception/Application.php:112
/var/www/html/vendor/codeception/codeception/app.php:45
/var/www/html/vendor/codeception/codeception/app.php:46
/var/www/html/vendor/codeception/codeception/codecept:7
/var/www/html/vendor/bin/codecept:120


ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
  [Db] Disconnected from default

Provide test source code if related

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` binary(16) DEFAULT NULL,
  `name` varchar(30) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `is_active` bit(1) DEFAULT b'1',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


insert  into `users`(`id`,`uuid`, `name`,`email`, `is_active`,`created_at`) values (1,0x11edc34b01d972fa9c1d0242ac120006,'davert','[email protected]', b'1','2012-02-01 21:17:04');
    public function testSeeInDatabaseWithBinary()
    {
        $this->module->seeInDatabase('users', ['uuid' => hex2bin('11edc34b01d972fa9c1d0242ac120006')]);
    }

Details

  • Codeception version: 5.0.10
  • PHP Version: PHP 8.1.16 (cli)
  • Operating System: Linux
  • Installation type: Dockerized module-db
  • List of installed packages (composer show)
root@400b115c4f29:/var/www/html# composer show
behat/gherkin                      dev-master 01379b1 Gherkin DSL parser for PHP
codeception/codeception            5.0.x-dev ed4af7f  BDD-style testing framework
codeception/lib-asserts            2.1.0              Assertion methods used by Codeception core and Asserts module
codeception/stub                   4.1.0              Flexible Stub wrapper for PHPUnit's Mock Builder
myclabs/deep-copy                  1.x-dev 928a96f    Create deep copies (clones) of your objects
nikic/php-parser                   4.x-dev 0ffddce    A PHP parser written in PHP
phar-io/manifest                   dev-master 36d8a21 Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.2.1              Library for handling version information and constraints
phpunit/php-code-coverage          dev-main 489650a   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          dev-main 83f6271   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                dev-main 5994330   Invoke callables with a timeout
phpunit/php-text-template          dev-main 9914010   Simple template engine.
phpunit/php-timer                  dev-main fe67739   Utility class for timing
phpunit/phpunit                    dev-main 38f35a7   The PHP Unit Testing framework.
psr/container                      dev-master 90db7b9 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher               dev-master e275e2d Standard interfaces for event handling.
psy/psysh                          dev-main 6c8c0fd   An interactive shell for modern PHP.
sebastian/cli-parser               dev-main 9215d45   Library for parsing CLI options
sebastian/code-unit                dev-main 362736b   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup dev-main cd740da   Looks up which function or method a line of code belongs to
sebastian/comparator               dev-main 5d09783   Provides the functionality to compare PHP values for equality
sebastian/complexity               dev-main 27d3bd5   Library for calculating the complexity of PHP code units
sebastian/diff                     dev-main 2c9aad8   Diff implementation
sebastian/environment              dev-main 54b3f6e   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 dev-main d6e9b3c   Provides the functionality to export PHP variables for visualization
sebastian/global-state             dev-main 3b3c08e   Snapshotting of global state
sebastian/lines-of-code            dev-main a1e716d   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        dev-main ac568e5   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         dev-main 4bf3974   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        dev-main 8343512   Provides functionality to recursively process PHP variables
sebastian/type                     dev-main 1a33327   Collection of value objects that represent the types of the PHP type system
sebastian/version                  dev-main a7fa65c   Library that helps with managing the version number of Git-hosted PHP projects
symfony/console                    6.3.x-dev 2655810  Eases the creation of beautiful and testable command line interfaces
symfony/css-selector               6.3.x-dev efc0747  Converts CSS selectors to XPath expressions
symfony/deprecation-contracts      dev-main e2d1534   A generic function and convention to trigger deprecation notices
symfony/event-dispatcher           6.3.x-dev 7fa6112  Provides tools that allow your application components to communicate with each other by dispatching events and lis...
symfony/event-dispatcher-contracts dev-main 0ad3b6f   Generic abstractions related to dispatching event
symfony/finder                     6.3.x-dev f5891f0  Finds files and directories via an intuitive fluent interface
symfony/polyfill-ctype             dev-main ea208ce   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme     dev-main 875e90a   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer   dev-main 8c4ad05   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          dev-main f9c7aff   Symfony polyfill for the Mbstring extension
symfony/service-contracts          dev-main a8c9ced   Generic abstractions related to writing services
symfony/string                     6.3.x-dev 599f0f0  Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unif...
symfony/var-dumper                 6.3.x-dev 42237ee  Provides mechanisms for walking through any arbitrary PHP variable
symfony/yaml                       6.3.x-dev 55071ed  Loads and dumps YAML files
theseer/tokenizer                  1.2.1              A small library for converting tokenized PHP source code into XML and potentially other formats
cybd pushed a commit to cybd/module-db that referenced this issue Mar 15, 2023
cybd pushed a commit to cybd/module-db that referenced this issue Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant