Lines 21-26
Link Here
|
21 |
|
21 |
|
22 |
use Modern::Perl; |
22 |
use Modern::Perl; |
23 |
use Test::More tests => 11; |
23 |
use Test::More tests => 11; |
|
|
24 |
use Test::Exception; |
24 |
use Time::HiRes qw|usleep|; |
25 |
use Time::HiRes qw|usleep|; |
25 |
use C4::Context; |
26 |
use C4::Context; |
26 |
use Koha::Token; |
27 |
use Koha::Token; |
Lines 91-101
subtest 'Same logged in user with another session (cookie CGISESSID)' => sub {
Link Here
|
91 |
}; |
92 |
}; |
92 |
|
93 |
|
93 |
subtest 'Pattern parameter' => sub { |
94 |
subtest 'Pattern parameter' => sub { |
94 |
plan tests => 4; |
95 |
plan tests => 5; |
95 |
my $id = $tokenizer->generate({ pattern => '\d\d', length => 8 }); |
96 |
my $id = $tokenizer->generate({ pattern => '\d\d', length => 8 }); |
96 |
is( length($id), 2, 'Pattern overrides length' ); |
97 |
is( length($id), 2, 'Pattern overrides length' ); |
97 |
ok( $id =~ /\d{2}/, 'Two digits found' ); |
98 |
ok( $id =~ /\d{2}/, 'Two digits found' ); |
98 |
$id = $tokenizer->generate({ pattern => '[A-Z]{10}' }); |
99 |
$id = $tokenizer->generate({ pattern => '[A-Z]{10}' }); |
99 |
is( length($id), 10, 'Check length again' ); |
100 |
is( length($id), 10, 'Check length again' ); |
100 |
ok( $id !~ /[^A-Z]/, 'Only uppercase letters' ); |
101 |
ok( $id !~ /[^A-Z]/, 'Only uppercase letters' ); |
|
|
102 |
throws_ok( sub { $tokenizer->generate({ pattern => 'abc[', }) }, 'Koha::Exceptions::Token::BadPattern', 'Exception should be thrown when wrong pattern is used'); |
101 |
}; |
103 |
}; |
102 |
- |
|
|