@@ -27,7 +27,7 @@ public function testNonUtfChars(): void
2727 /** @var Database $database */
2828 $ database = $ this ->getDatabase ();
2929
30- if (!$ database ->getAdapter ()->getSupportNonUtcCharacters ()) {
30+ if (!$ database ->getAdapter ()->getSupportNonUtfCharacters ()) {
3131 $ this ->expectNotToPerformAssertions ();
3232 return ;
3333 }
@@ -46,15 +46,24 @@ public function testNonUtfChars(): void
4646 $ this ->assertTrue ($ e instanceof CharacterException);
4747 }
4848
49- $ nonUtfString = iconv ('UTF-8 ' , 'UTF-8//IGNORE ' , $ nonUtfString ); // removes invalid UTF-8
50- $ nonUtfString = str_replace ("\0" , '' , $ nonUtfString ); // remove null bytes
49+ $ nonUtfString = "Hello \x00World \xC3\x28\xFF\xFE\xA0Test \x00End " ;
50+
51+ /**
52+ * Convert to UTF-8 and replace invalid bytes with empty string
53+ */
54+ $ nonUtfString = mb_convert_encoding ($ nonUtfString , 'UTF-8 ' , 'UTF-8 ' );
55+
56+ /**
57+ * Remove null bytes
58+ */
59+ $ nonUtfString = str_replace ("\0" , '' , $ nonUtfString );
5160
5261 $ document = $ database ->createDocument (__FUNCTION__ , new Document ([
5362 'title ' => $ nonUtfString ,
5463 ]));
5564
5665 $ this ->assertFalse ($ document ->isEmpty ());
57- $ this ->assertEquals ('HelloWorld( TestEnd ' , $ document ->getAttribute ('title ' ));
66+ $ this ->assertEquals ('HelloWorld?(??? TestEnd ' , $ document ->getAttribute ('title ' ));
5867 }
5968
6069 public function testBigintSequence (): void
0 commit comments