Lines 44-51
subtest 'request() tests' => sub {
Link Here
|
44 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { lastseen => undef } } ); |
44 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { lastseen => undef } } ); |
45 |
my $item = $builder->build_sample_item; |
45 |
my $item = $builder->build_sample_item; |
46 |
|
46 |
|
47 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
47 |
my $ar_module = mock_article_request_module(); |
48 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
49 |
|
48 |
|
50 |
my $ar = Koha::ArticleRequest->new( |
49 |
my $ar = Koha::ArticleRequest->new( |
51 |
{ |
50 |
{ |
Lines 100-107
subtest 'set_pending() tests' => sub {
Link Here
|
100 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
99 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
101 |
my $biblio = $builder->build_sample_biblio; |
100 |
my $biblio = $builder->build_sample_biblio; |
102 |
|
101 |
|
103 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
102 |
my $ar_module = mock_article_request_module(); |
104 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
105 |
|
103 |
|
106 |
my $ar = Koha::ArticleRequest->new( |
104 |
my $ar = Koha::ArticleRequest->new( |
107 |
{ |
105 |
{ |
Lines 124-131
subtest 'process() tests' => sub {
Link Here
|
124 |
|
122 |
|
125 |
$schema->storage->txn_begin; |
123 |
$schema->storage->txn_begin; |
126 |
|
124 |
|
127 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
125 |
my $ar_module = mock_article_request_module(); |
128 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
129 |
|
126 |
|
130 |
my $ar = $builder->build_object( |
127 |
my $ar = $builder->build_object( |
131 |
{ class => 'Koha::ArticleRequests', |
128 |
{ class => 'Koha::ArticleRequests', |
Lines 146-153
subtest 'complete() tests' => sub {
Link Here
|
146 |
|
143 |
|
147 |
$schema->storage->txn_begin; |
144 |
$schema->storage->txn_begin; |
148 |
|
145 |
|
149 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
146 |
my $ar_module = mock_article_request_module(); |
150 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
151 |
|
147 |
|
152 |
my $ar = $builder->build_object( |
148 |
my $ar = $builder->build_object( |
153 |
{ class => 'Koha::ArticleRequests', |
149 |
{ class => 'Koha::ArticleRequests', |
Lines 176-183
subtest 'cancel() tests' => sub {
Link Here
|
176 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
172 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
177 |
my $item = $builder->build_sample_item; |
173 |
my $item = $builder->build_sample_item; |
178 |
|
174 |
|
179 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
175 |
my $ar_module = mock_article_request_module(); |
180 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
181 |
|
176 |
|
182 |
my $ar = Koha::ArticleRequest->new( |
177 |
my $ar = Koha::ArticleRequest->new( |
183 |
{ |
178 |
{ |
Lines 225-227
subtest 'store' => sub {
Link Here
|
225 |
|
220 |
|
226 |
$schema->storage->txn_rollback; |
221 |
$schema->storage->txn_rollback; |
227 |
}; |
222 |
}; |
228 |
- |
223 |
|
|
|
224 |
sub mock_article_request_module { |
225 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
226 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
227 |
$ar_mock->mock( |
228 |
'format', |
229 |
sub { |
230 |
my $formats = C4::Context->multivalue_preference('ArticleRequestsSupportedFormats'); |
231 |
return $formats->[ int( rand( scalar @$formats ) ) ]; |
232 |
} |
233 |
); |
234 |
return $ar_mock; |
235 |
} |