1# -- 2# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ 3# -- 4# This software comes with ABSOLUTELY NO WARRANTY. For details, see 5# the enclosed file COPYING for license information (GPL). If you 6# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt. 7# -- 8 9use strict; 10use warnings; 11use utf8; 12 13use vars (qw($Self)); 14 15my @Tests = ( 16 { 17 Name => 'Empty request', 18 Config => {}, 19 Result => 'O', 20 }, 21 { 22 Name => 'Invalid name', 23 Config => { 24 Fullname => '~!@#$%^ &*()_+=', # non-word characters only 25 }, 26 Result => 'O', 27 }, 28 { 29 Name => 'Generic - John Doe', 30 Config => { 31 Fullname => 'John Doe', 32 }, 33 Result => 'JD', 34 }, 35 { 36 Name => 'Capitalization - jOhN dOe', 37 Config => { 38 Fullname => 'John Doe', 39 }, 40 Result => 'JD', 41 }, 42 { 43 Name => 'Mixed - "John Doe"', 44 Config => { 45 Fullname => '"John Doe"', 46 }, 47 Result => 'JD', 48 }, 49 { 50 Name => 'With email - "John Doe" <jdoe@example.com>', 51 Config => { 52 Fullname => '"John Doe" <jdoe@example.com>', 53 }, 54 Result => 'JD', 55 }, 56 { 57 Name => 'With something in brackets - John Doe (jdoe)', 58 Config => { 59 Fullname => 'John Doe (jdoe)', 60 }, 61 Result => 'JD', 62 }, 63 { 64 Name => 'Only one name - Joe', 65 Config => { 66 Fullname => 'Joe', 67 }, 68 Result => 'J', 69 }, 70 { 71 Name => 'Cyrillic - Петар Петровић', 72 Config => { 73 Fullname => 'Петар Петровић', 74 }, 75 Result => 'ПП', 76 }, 77 { 78 Name => 'Chinese - 约翰·多伊', 79 Config => { 80 Fullname => '约翰·多伊', 81 }, 82 Result => '约', 83 }, 84); 85 86my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); 87 88for my $Test (@Tests) { 89 my $Result = $LayoutObject->UserInitialsGet( 90 %{ $Test->{Config} }, 91 ); 92 93 $Self->Is( 94 $Result, 95 $Test->{Result}, 96 "$Test->{Name} - Result" 97 ); 98} 99 1001; 101