Bug 9177 - Duplicate patron: Prepopulated fields ar cleared when setting cursor
[koha.git] / t / SIP_Sip.t
blob0346b4c2f4da7f2682a55005697f92ab813647af
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use Test::More tests => 9;
21 use Test::Warn;
23 BEGIN {
24 use FindBin;
25 use lib "$FindBin::Bin/../C4/SIP";
26 use_ok('C4::SIP::Sip');
29 my $date_time = Sip::timestamp();
30 like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format no param');
32 my $t = time();
34 $date_time = Sip::timestamp($t);
35 like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format secs');
37 $date_time = Sip::timestamp('2011-01-12');
38 ok( $date_time eq '20110112 235900', 'Timestamp iso date string');
40 my $myChecksum = Sip::Checksum::checksum("12345");
41 my $checker = 65281;
42 my $stringChecksum = Sip::Checksum::checksum("teststring");
43 my $stringChecker = 64425;
45 is( $myChecksum, $checker, "Checksum: $myChecksum matches expected output");
46 is( $stringChecksum, $stringChecker, "Checksum: $stringChecksum matches expected output");
48 my $testdata = "abcdAZ";
49 my $something = Sip::Checksum::checksum($testdata);
51 $something = sprintf("%4X", $something);
52 ok( Sip::Checksum::verify_cksum($testdata.$something), "Checksum: $something is valid.");
54 my $invalidTest;
55 warning_is { $invalidTest = Sip::Checksum::verify_cksum("1234567") }
56 'verify_cksum: no sum detected',
57 'verify_cksum prints the expected warning for an invalid checksum';
58 is($invalidTest, 0, "Checksum: 1234567 is invalid as expected");