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

(-)a/t/db_dependent/ArticleRequests.t (-24 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 55;
22
use Test::More tests => 54;
23
use Test::MockModule;
23
use Test::MockModule;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 251-276 subtest 'may_article_request' => sub { Link Here
251
};
251
};
252
252
253
$schema->storage->txn_rollback();
253
$schema->storage->txn_rollback();
254
255
subtest 'set_pending() tests' => sub {
256
257
    plan tests => 2;
258
259
    $schema->storage->txn_begin;
260
261
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
262
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
263
264
    my $ar = $builder->build_object(
265
        {
266
            class => 'Koha::ArticleRequests',
267
            value => { status => Koha::ArticleRequest::Status::Requested }
268
        }
269
    );
270
271
    $ar->set_pending()->discard_changes;
272
273
    is( $ar->status, Koha::ArticleRequest::Status::Pending );
274
275
    $schema->storage->txn_rollback;
276
};
(-)a/t/db_dependent/Koha/ArticleRequest.t (-1 / +137 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 => 5;
21
use Test::MockModule;
22
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
26
my $schema  = Koha::Database->new->schema;
27
my $builder = t::lib::TestBuilder->new;
28
29
subtest 'request() tests' => sub {
30
31
    plan tests => 2;
32
33
    $schema->storage->txn_begin;
34
35
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
36
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
37
38
    my $ar = $builder->build_object(
39
        {   class => 'Koha::ArticleRequests',
40
            value => { status => Koha::ArticleRequest::Status::Pending }
41
        }
42
    );
43
44
    $ar->request()->discard_changes;
45
46
    is( $ar->status, Koha::ArticleRequest::Status::Requested );
47
48
    $schema->storage->txn_rollback;
49
};
50
51
subtest 'set_pending() tests' => sub {
52
53
    plan tests => 2;
54
55
    $schema->storage->txn_begin;
56
57
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
58
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
59
60
    my $ar = $builder->build_object(
61
        {   class => 'Koha::ArticleRequests',
62
            value => { status => Koha::ArticleRequest::Status::Requested }
63
        }
64
    );
65
66
    $ar->set_pending()->discard_changes;
67
68
    is( $ar->status, Koha::ArticleRequest::Status::Pending );
69
70
    $schema->storage->txn_rollback;
71
};
72
73
subtest 'process() tests' => sub {
74
75
    plan tests => 2;
76
77
    $schema->storage->txn_begin;
78
79
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
80
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
81
82
    my $ar = $builder->build_object(
83
        {   class => 'Koha::ArticleRequests',
84
            value => { status => Koha::ArticleRequest::Status::Requested }
85
        }
86
    );
87
88
    $ar->process()->discard_changes;
89
90
    is( $ar->status, Koha::ArticleRequest::Status::Processing );
91
92
    $schema->storage->txn_rollback;
93
};
94
95
subtest 'complete() tests' => sub {
96
97
    plan tests => 2;
98
99
    $schema->storage->txn_begin;
100
101
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
102
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
103
104
    my $ar = $builder->build_object(
105
        {   class => 'Koha::ArticleRequests',
106
            value => { status => Koha::ArticleRequest::Status::Requested }
107
        }
108
    );
109
110
    $ar->complete()->discard_changes;
111
112
    is( $ar->status, Koha::ArticleRequest::Status::Completed );
113
114
    $schema->storage->txn_rollback;
115
};
116
117
subtest 'cancel() tests' => sub {
118
119
    plan tests => 2;
120
121
    $schema->storage->txn_begin;
122
123
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
124
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
125
126
    my $ar = $builder->build_object(
127
        {   class => 'Koha::ArticleRequests',
128
            value => { status => Koha::ArticleRequest::Status::Requested }
129
        }
130
    );
131
132
    $ar->cancel()->discard_changes;
133
134
    is( $ar->status, Koha::ArticleRequest::Status::Canceled );
135
136
    $schema->storage->txn_rollback;
137
};

Return to bug 27944