File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
system/Commands/Utilities
tests/system/Commands/Utilities Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,10 @@ private function outputAllNamespaces(array $params): array
120120
121121 private function truncate (string $ string , int $ max ): string
122122 {
123- $ length = strlen ($ string );
123+ $ length = mb_strlen ($ string );
124124
125125 if ($ length > $ max ) {
126- return substr ($ string , 0 , $ max - 3 ) . '... ' ;
126+ return mb_substr ($ string , 0 , $ max - 3 ) . '... ' ;
127127 }
128128
129129 return $ string ;
Original file line number Diff line number Diff line change 1414namespace CodeIgniter \Commands \Utilities ;
1515
1616use CodeIgniter \Test \CIUnitTestCase ;
17+ use CodeIgniter \Test \ReflectionHelper ;
1718use CodeIgniter \Test \StreamFilterTrait ;
1819use PHPUnit \Framework \Attributes \Group ;
1920
2425final class NamespacesTest extends CIUnitTestCase
2526{
2627 use StreamFilterTrait;
28+ use ReflectionHelper;
2729
2830 protected function setUp (): void
2931 {
@@ -84,4 +86,14 @@ public function testNamespacesCommandAllNamespaces(): void
8486 str_replace (' ' , '' , $ this ->getBuffer ())
8587 );
8688 }
89+
90+ public function testTruncateNamespaces (): void
91+ {
92+ $ commandObject = new Namespaces (service ('logger ' ), service ('commands ' ));
93+ $ truncateRunner = $ this ->getPrivateMethodInvoker ($ commandObject , 'truncate ' );
94+
95+ $ this ->assertSame ('App\Controllers\... ' , $ truncateRunner ('App\Controllers\Admin ' , 19 ));
96+ // multibyte namespace
97+ $ this ->assertSame ('App\Контроллеры\... ' , $ truncateRunner ('App\Контроллеры\Админ ' , 19 ));
98+ }
8799}
You can’t perform that action at this time.
0 commit comments