@@ -346,6 +346,69 @@ public function testGetColumnNoExist(): void
346346 $ this ->assertNull ($ table ->getColumn ('no_exist ' ));
347347 }
348348
349+ public function testQuoterEscapingValue ()
350+ {
351+ $ db = $ this ->getConnection (true );
352+ $ quoter = $ db ->getQuoter ();
353+
354+ $ db ->createCommand ('delete from {{quoter}} ' )->execute ();
355+ $ data = $ this ->generateQuoterEscapingValues ();
356+
357+ foreach ($ data as $ index => $ value ) {
358+ $ quotedName = $ quoter ->quoteValue ('testValue_ ' . $ index );
359+ $ quoteValue = $ quoter ->quoteValue ($ value );
360+
361+ $ db ->createCommand ('insert into {{quoter}}([[name]], [[description]]) values( ' . $ quotedName . ', ' . $ quoteValue . ') ' )->execute ();
362+ $ result = $ db ->createCommand ('select * from {{quoter}} where [[name]]= ' . $ quotedName )->queryOne ();
363+ $ this ->assertEquals ($ value , $ result ['description ' ]);
364+ }
365+ }
366+
367+ public function generateQuoterEscapingValues ()
368+ {
369+ $ result = [];
370+ $ stringLength = 16 ;
371+ for ($ i = 1 ; $ i < 128 - $ stringLength ; $ i += $ stringLength ) {
372+ $ str = '' ;
373+ for ($ symbol = $ i ; $ symbol < $ i + $ stringLength ; $ symbol ++) {
374+ $ str .= mb_chr ($ symbol , 'UTF-8 ' );
375+ }
376+ $ result [] = $ str ;
377+
378+ $ str = '' ;
379+ for ($ symbol = $ i ; $ symbol < $ i + $ stringLength ; $ symbol ++) {
380+ $ str .= mb_chr ($ symbol , 'UTF-8 ' ) . mb_chr ($ symbol , 'UTF-8 ' );
381+ }
382+ $ result [] = $ str ;
383+ }
384+
385+ return $ result ;
386+ }
387+
388+ public function testQuoterEscapingValueFull ()
389+ {
390+ $ this ->markTestSkipped ('Very long test - only for check quoteValue ' );
391+ $ template = 'aaaaa{1}aaa{1}aaaabbbbb{2}bbbb{2}bbbb ' ;
392+
393+ $ db = $ this ->getConnection (true );
394+ $ quoter = $ db ->getQuoter ();
395+
396+ $ db ->createCommand ('delete from {{quoter}} ' )->execute ();
397+
398+ for ($ symbol1 = 1 ; $ symbol1 <= 127 ; $ symbol1 ++) {
399+ for ($ symbol2 = 1 ; $ symbol2 <= 127 ; $ symbol2 ++) {
400+ $ quotedName = $ quoter ->quoteValue ('test_ ' . $ symbol1 . '_ ' . $ symbol2 );
401+ $ testString = str_replace (['{1} ' , '{2} ' ,], [chr ($ symbol1 ), chr ($ symbol2 )], $ template );
402+
403+ $ quoteValue = $ quoter ->quoteValue ($ testString );
404+
405+ $ db ->createCommand ('insert into {{quoter}}([[name]], [[description]]) values( ' . $ quotedName . ', ' . $ quoteValue . ') ' )->execute ();
406+ $ result = $ db ->createCommand ('select * from {{quoter}} where [[name]]= ' . $ quotedName )->queryOne ();
407+ $ this ->assertEquals ($ testString , $ result ['description ' ]);
408+ }
409+ }
410+ }
411+
349412 private function assertMetadataEquals ($ expected , $ actual ): void
350413 {
351414 switch (strtolower (gettype ($ expected ))) {
0 commit comments