View | Details | Raw Unified | Return to bug 21178
Collapse All | Expand All

(-)a/Koha/Exceptions/Password.pm (+20 lines)
Lines 41-46 use Exception::Class ( Link Here
41
    }
41
    }
42
);
42
);
43
43
44
sub full_message {
45
    my $self = shift;
46
47
    my $msg = $self->message;
48
49
    unless ( $msg) {
50
        if ( $self->isa('Koha::Exceptions::Password::TooShort') ) {
51
            $msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length );
52
        }
53
    }
54
55
    return $msg;
56
}
57
44
=head1 NAME
58
=head1 NAME
45
59
46
Koha::Exceptions::Password - Base class for password exceptions
60
Koha::Exceptions::Password - Base class for password exceptions
Lines 67-72 Password is too weak. Link Here
67
81
68
Password contains trailing spaces, which is forbidden.
82
Password contains trailing spaces, which is forbidden.
69
83
84
=head1 Class methods
85
86
=head2 full_message
87
88
Overloaded method for exception stringifying.
89
70
=cut
90
=cut
71
91
72
1;
92
1;
(-)a/t/Koha/Exceptions.t (-2 / +21 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 1;
20
use Test::More tests => 2;
21
use Test::Exception;
21
use Test::Exception;
22
22
23
subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub {
23
subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub {
Lines 41-43 subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub { Link Here
41
    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
41
    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
42
};
42
};
43
43
44
- 
44
subtest 'Koha::Exceptions::Password tests' => sub {
45
46
    plan tests => 5;
47
48
    use_ok('Koha::Exceptions::Password');
49
50
    throws_ok
51
        { Koha::Exceptions::Password::TooShort->throw( length => 4, min_length => 5 ); }
52
        'Koha::Exceptions::Password::TooShort',
53
        'Exception is thrown :-D';
54
55
    # stringify the exception
56
    is( "$@", 'Password length (4) is shorter than required (5)', 'Exception stringified correctly' );
57
58
    throws_ok
59
        { Koha::Exceptions::Password::TooShort->throw( "Manual message exception" ) }
60
        'Koha::Exceptions::Password::TooShort',
61
        'Exception is thrown :-D';
62
    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
63
};

Return to bug 21178