Bug 7567: convert news add/update routines to take hashref; fix bugs
[koha.git] / t / db_dependent / BackgroundJob.t
1 #!/usr/bin/perl
2 #
3 # This Koha test module is a stub!  
4 # Add more tests here!!!
5
6 use strict;
7 use warnings;
8 use C4::Auth;
9 use CGI;
10 use Test::More tests => 14;
11
12 BEGIN {
13         use_ok('C4::BackgroundJob');
14 }
15 my $query = new CGI;
16 my ($userid, $cookie, $sessionID) = &checkauth($query, 1);
17 #my ($sessionID, $job_name, $job_invoker, $num_work_units) = @_;
18 my $background;
19 diag $sessionID;
20 ok ($background=C4::BackgroundJob->new($sessionID), "making job");
21 ok ($background->id, "fetching id number");
22
23 $background->name("George");
24 is ($background->name, "George", "testing name");
25
26 $background->invoker("enjoys");
27 is ($background->invoker, "enjoys", "testing invoker");
28
29 $background->progress("testing");
30 is ($background->progress, "testing", "testing progress");
31
32 ok ($background->status, "testing status");
33
34 $background->size("56");
35 is ($background->size, "56", "testing size");
36
37 ok (!$background->fetch($sessionID, $background->id), "testing fetch");
38
39 $background->set({ key1 => 'value1', key2 => 'value2' });
40 is ($background->get('key1'), 'value1', 'fetched extra value for key key1');
41 is ($background->get('key2'), 'value2', 'fetched extra value for key key2');
42
43 $background->set({ size => 666 });
44 is ($background->size, "56", '->set() does not scribble over private object data');
45
46 $background->finish("finished");
47 is ($background->status,'completed', "testing finished");
48
49 ok ($background->results); #Will return undef unless finished