Bug 27272: Remove GetItemsInfo, GetItemsLocationInfo and GetHostItemsInfo
[koha-ffzg.git] / t / db_dependent / BackgroundJob.t
old mode 100644 (file)
new mode 100755 (executable)
index ae5c25a..459f3b2
@@ -1,16 +1,16 @@
 #!/usr/bin/perl
 
 use Modern::Perl;
-use C4::Auth;
+use C4::Auth qw( get_session );
 use CGI qw ( -utf8 );
 use Test::More tests => 18;
 
 use Koha::Database;
 
 BEGIN {
-    use_ok('C4::BackgroundJob');
+    use_ok('C4::BackgroundJob', qw( get id fetch name invoker progress status size set finish results clear ));
 }
-my $query = new CGI;
+my $query = CGI->new;
 
 my $schema = Koha::Database->new->schema;
 $schema->storage->txn_begin;
@@ -47,13 +47,11 @@ is( $job->size, "56", '->set() does not scribble over private object data' );
 $job->finish("finished");
 is( $job->status, 'completed', "testing finished" );
 
-ok( $job->results );    #Will return undef unless finished
+ok( $job->results, 'Test if we have results' );
 
 my $second_job = C4::BackgroundJob->new( $sessionID, "making new job" );
-$session = C4::Auth::get_session( $job->{sessionID} );
-is( ref( $session->param( 'job_' . $job->id ) ),        "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 1' );
-is( ref( $session->param( 'job_' . $second_job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 2' );
+is( ref( C4::BackgroundJob->fetch( $sessionID, $job->id ) ),        "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 1' );
+is( ref( C4::BackgroundJob->fetch( $sessionID, $second_job->id ) ), "C4::BackgroundJob", 'job_$jobid should be a C4::BackgroundJob for uncleared job 2' );
 $job->clear;
-$session = C4::Auth::get_session( $job->{sessionID} );
-is( $session->param( 'job_' . $job->id ), undef, 'After clearing it, job 1 should not exist anymore in the session' );
-is( ref( $session->param( 'job_' . $second_job->id ) ), "C4::BackgroundJob", 'After clear on job 1, job 2 should still be a C4::BackgroundJob' );
+is( C4::BackgroundJob->fetch( $sessionID, $job->id ), undef, 'After clearing it, job 1 should not exist anymore in the session' );
+is( ref( C4::BackgroundJob->fetch( $sessionID, $second_job->id ) ), "C4::BackgroundJob", 'After clear on job 1, job 2 should still be a C4::BackgroundJob' );