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

(-)a/t/db_dependent/Koha/BackgroundJob/BatchCancelHold.t (+49 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchCancelHold;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $reason   = 'Some reason';
39
    my $hold_ids = [ 1, 2 ];
40
41
    my $job_id = Koha::BackgroundJob::BatchCancelHold->new->enqueue( { hold_ids => $hold_ids }, reason => $reason );
42
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
43
44
    is( $job->size,   scalar @{$hold_ids}, 'Size is correct' );
45
    is( $job->status, 'new',               'Initial status set correctly' );
46
    is( $job->queue,  'long_tasks',        'BatchUpdateItem should use the long_tasks queue' );
47
48
    $schema->storage->txn_rollback;
49
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchDeleteAuthority.t (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchDeleteAuthority;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $record_ids = [ 1, 2 ];
39
40
    my $job_id = Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue( { record_ids => $record_ids } );
41
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
42
43
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
44
    is( $job->status, 'new',                 'Initial status set correctly' );
45
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
46
47
    $schema->storage->txn_rollback;
48
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchDeleteBiblio.t (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchDeleteBiblio;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $record_ids = [ 1, 2 ];
39
40
    my $job_id = Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue( { record_ids => $record_ids } );
41
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
42
43
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
44
    is( $job->status, 'new',                 'Initial status set correctly' );
45
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
46
47
    $schema->storage->txn_rollback;
48
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchDeleteItem.t (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchDeleteItem;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $record_ids = [ 1, 2 ];
39
40
    my $job_id = Koha::BackgroundJob::BatchDeleteItem->new->enqueue( { record_ids => $record_ids } );
41
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
42
43
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
44
    is( $job->status, 'new',                 'Initial status set correctly' );
45
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
46
47
    $schema->storage->txn_rollback;
48
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchUpdateAuthority.t (+56 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchUpdateAuthority;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 5;
35
36
    $schema->storage->txn_begin;
37
38
    # FIXME: Should be an exception
39
    my $job_id = Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue();
40
    is( $job_id, undef, 'Nothing enqueued if missing params' );
41
42
    # FIXME: Should be an exception
43
    $job_id = Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue( { record_ids => undef } );
44
    is( $job_id, undef, "Nothing enqueued if missing 'mmtid' param" );
45
46
    my $record_ids = [ 1, 2 ];
47
48
    $job_id = Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue( { record_ids => $record_ids, mmtid => 'thing' } );
49
    my $job = Koha::BackgroundJobs->find($job_id)->_derived_class;
50
51
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
52
    is( $job->status, 'new',                 'Initial status set correctly' );
53
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
54
55
    $schema->storage->txn_rollback;
56
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchUpdateBiblio.t (+56 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchUpdateBiblio;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 5;
35
36
    $schema->storage->txn_begin;
37
38
    # FIXME: Should be an exception
39
    my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue();
40
    is( $job_id, undef, 'Nothing enqueued if missing params' );
41
42
    # FIXME: Should be an exception
43
    $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue( { record_ids => undef } );
44
    is( $job_id, undef, "Nothing enqueued if missing 'mmtid' param" );
45
46
    my $record_ids = [ 1, 2 ];
47
48
    $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue( { record_ids => $record_ids, mmtid => 'thing' } );
49
    my $job = Koha::BackgroundJobs->find($job_id)->_derived_class;
50
51
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
52
    is( $job->status, 'new',                 'Initial status set correctly' );
53
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
54
55
    $schema->storage->txn_rollback;
56
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchUpdateBiblioHoldsQueue.t (+56 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
use Test::Exception;
22
23
use Koha::Database;
24
use Koha::BackgroundJobs;
25
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
26
27
use t::lib::Mocks;
28
use t::lib::TestBuilder;
29
30
my $schema  = Koha::Database->new->schema;
31
my $builder = t::lib::TestBuilder->new;
32
33
subtest 'enqueue() tests' => sub {
34
35
    plan tests => 5;
36
37
    $schema->storage->txn_begin;
38
39
    my $biblio_ids = [ 1, 2 ];
40
41
    throws_ok
42
        { Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue() }
43
        'Koha::Exceptions::MissingParameter',
44
        "Exception thrown if 'biblio_ids' param is missing";
45
46
    like( "$@", qr/Missing biblio_ids parameter is mandatory/, 'Expected exception message' );
47
48
    my $job_id = Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => $biblio_ids } );
49
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
50
51
    is( $job->size,   scalar @{$biblio_ids}, 'Size is correct' );
52
    is( $job->status, 'new',                 'Initial status set correctly' );
53
    is( $job->queue,  'default',             'BatchUpdateItem should use the default queue' );
54
55
    $schema->storage->txn_rollback;
56
};
(-)a/t/db_dependent/Koha/BackgroundJob/BatchUpdateItem.t (+48 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::BatchUpdateItem;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $record_ids = [ 1, 2 ];
39
40
    my $job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => $record_ids } );
41
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
42
43
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
44
    is( $job->status, 'new',                 'Initial status set correctly' );
45
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
46
47
    $schema->storage->txn_rollback;
48
};
(-)a/t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t (+56 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::CreateEHoldingsFromBiblios;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 5;
35
36
    $schema->storage->txn_begin;
37
38
    # FIXME: Should be an exception
39
    my $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue();
40
    is( $job_id, undef, 'Nothing enqueued if missing params' );
41
42
    # FIXME: Should be an exception
43
    $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue( { record_ids => undef } );
44
    is( $job_id, undef, "Nothing enqueued if missing 'package_id' param" );
45
46
    my $record_ids = [ 1, 2 ];
47
48
    $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue( { record_ids => $record_ids, package_id => 'thing' } );
49
    my $job = Koha::BackgroundJobs->find($job_id)->_derived_class;
50
51
    is( $job->size,   scalar @{$record_ids}, 'Size is correct' );
52
    is( $job->status, 'new',                 'Initial status set correctly' );
53
    is( $job->queue,  'long_tasks',          'BatchUpdateItem should use the long_tasks queue' );
54
55
    $schema->storage->txn_rollback;
56
};
(-)a/t/db_dependent/Koha/BackgroundJob/MARCImportCommitBatch.t (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::MARCImportCommitBatch;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $import_batch = $builder->build_object({ class => 'Koha::ImportBatches' });
39
    # Add two records
40
    $builder->build_object({ class => 'Koha::Import::Records', value => { import_batch_id => $import_batch->id } });
41
    $builder->build_object({ class => 'Koha::Import::Records', value => { import_batch_id => $import_batch->id } });
42
43
    my $job_id = Koha::BackgroundJob::MARCImportCommitBatch->new->enqueue( { import_batch_id => $import_batch->id } );
44
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
45
46
    is( $job->size,   2,            'Size is correct' );
47
    is( $job->status, 'new',        'Initial status set correctly' );
48
    is( $job->queue,  'long_tasks', 'BatchUpdateItem should use the long_tasks queue' );
49
50
    $schema->storage->txn_rollback;
51
};
(-)a/t/db_dependent/Koha/BackgroundJob/MARCImportRevertBatch.t (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::MARCImportRevertBatch;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $import_batch = $builder->build_object({ class => 'Koha::ImportBatches' });
39
    # Add two records
40
    $builder->build_object({ class => 'Koha::Import::Records', value => { import_batch_id => $import_batch->id } });
41
    $builder->build_object({ class => 'Koha::Import::Records', value => { import_batch_id => $import_batch->id } });
42
43
    my $job_id = Koha::BackgroundJob::MARCImportRevertBatch->new->enqueue( { import_batch_id => $import_batch->id } );
44
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
45
46
    is( $job->size,   2,            'Size is correct' );
47
    is( $job->status, 'new',        'Initial status set correctly' );
48
    is( $job->queue,  'long_tasks', 'BatchUpdateItem should use the long_tasks queue' );
49
50
    $schema->storage->txn_rollback;
51
};
(-)a/t/db_dependent/Koha/BackgroundJob/StageMARCForImport.t (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::StageMARCForImport;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 3;
35
36
    $schema->storage->txn_begin;
37
38
    my $job_id = Koha::BackgroundJob::StageMARCForImport->new->enqueue();
39
    my $job    = Koha::BackgroundJobs->find($job_id)->_derived_class;
40
41
    is( $job->size,   0,            'Size is correct' );
42
    is( $job->status, 'new',        'Initial status set correctly' );
43
    is( $job->queue,  'long_tasks', 'BatchUpdateItem should use the long_tasks queue' );
44
45
    $schema->storage->txn_rollback;
46
};
(-)a/t/db_dependent/Koha/BackgroundJob/UpdateElasticIndex.t (-1 / +56 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
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.
9
#
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.
14
#
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>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
22
use Koha::Database;
23
use Koha::BackgroundJobs;
24
use Koha::BackgroundJob::UpdateElasticIndex;
25
26
use t::lib::Mocks;
27
use t::lib::TestBuilder;
28
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
subtest 'enqueue() tests' => sub {
33
34
    plan tests => 5;
35
36
    $schema->storage->txn_begin;
37
38
    # FIXME: Should be an exception
39
    my $job_id = Koha::BackgroundJob::UpdateElasticIndex->new->enqueue();
40
    is( $job_id, undef, 'Nothing enqueued if missing params' );
41
42
    # FIXME: Should be an exception
43
    $job_id = Koha::BackgroundJob::UpdateElasticIndex->new->enqueue( { record_ids => undef } );
44
    is( $job_id, undef, "Nothing enqueued if missing 'record_server' param" );
45
46
    my $record_ids = [ 1, 2 ];
47
48
    $job_id = Koha::BackgroundJob::UpdateElasticIndex->new->enqueue( { record_ids => $record_ids, record_server => 'thing' } );
49
    my $job = Koha::BackgroundJobs->find($job_id)->_derived_class;
50
51
    is( $job->size,   1,         'Size is correct' );
52
    is( $job->status, 'new',     'Initial status set correctly' );
53
    is( $job->queue,  'default', 'BatchUpdateItem should use the default queue' );
54
55
    $schema->storage->txn_rollback;
56
};

Return to bug 32394