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 |
{ |
128 |
{ |
Lines 147-154
subtest 'complete() tests' => sub {
Link Here
|
147 |
|
144 |
|
148 |
$schema->storage->txn_begin; |
145 |
$schema->storage->txn_begin; |
149 |
|
146 |
|
150 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
147 |
my $ar_module = mock_article_request_module(); |
151 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
152 |
|
148 |
|
153 |
my $ar = $builder->build_object( |
149 |
my $ar = $builder->build_object( |
154 |
{ |
150 |
{ |
Lines 178-185
subtest 'cancel() tests' => sub {
Link Here
|
178 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
174 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
179 |
my $item = $builder->build_sample_item; |
175 |
my $item = $builder->build_sample_item; |
180 |
|
176 |
|
181 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
177 |
my $ar_module = mock_article_request_module(); |
182 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
|
|
183 |
|
178 |
|
184 |
my $ar = Koha::ArticleRequest->new( |
179 |
my $ar = Koha::ArticleRequest->new( |
185 |
{ |
180 |
{ |
Lines 227-229
subtest 'store' => sub {
Link Here
|
227 |
|
222 |
|
228 |
$schema->storage->txn_rollback; |
223 |
$schema->storage->txn_rollback; |
229 |
}; |
224 |
}; |
230 |
- |
225 |
|
|
|
226 |
sub mock_article_request_module { |
227 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
228 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
229 |
$ar_mock->mock( |
230 |
'format', |
231 |
sub { |
232 |
my $formats = C4::Context->multivalue_preference('ArticleRequestsSupportedFormats'); |
233 |
return $formats->[ int( rand( scalar @$formats ) ) ]; |
234 |
} |
235 |
); |
236 |
return $ar_mock; |
237 |
} |