Lines 7-21
use t::lib::Mocks;
Link Here
|
7 |
use t::lib::TestBuilder; |
7 |
use t::lib::TestBuilder; |
8 |
use Koha::Database; |
8 |
use Koha::Database; |
9 |
use Koha::IssuingRules; |
9 |
use Koha::IssuingRules; |
|
|
10 |
use Koha::Caches; |
10 |
|
11 |
|
11 |
my $schema = Koha::Database->new->schema; |
12 |
my $schema = Koha::Database->new->schema; |
12 |
$schema->storage->txn_begin; |
13 |
$schema->storage->txn_begin; |
13 |
our $builder = t::lib::TestBuilder->new; |
14 |
our $builder = t::lib::TestBuilder->new; |
|
|
15 |
our $cache = Koha::Caches->get_instance; |
14 |
|
16 |
|
15 |
subtest 'guess_article_requestable_itemtypes' => sub { |
17 |
subtest 'guess_article_requestable_itemtypes' => sub { |
16 |
plan tests => 12; |
18 |
plan tests => 12; |
17 |
|
19 |
|
18 |
t::lib::Mocks::mock_preference('ArticleRequests', 1); |
20 |
t::lib::Mocks::mock_preference('ArticleRequests', 1); |
|
|
21 |
$cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); |
19 |
Koha::IssuingRules->delete; |
22 |
Koha::IssuingRules->delete; |
20 |
my $itype1 = $builder->build_object({ class => 'Koha::ItemTypes' }); |
23 |
my $itype1 = $builder->build_object({ class => 'Koha::ItemTypes' }); |
21 |
my $itype2 = $builder->build_object({ class => 'Koha::ItemTypes' }); |
24 |
my $itype2 = $builder->build_object({ class => 'Koha::ItemTypes' }); |
Lines 51-57
subtest 'guess_article_requestable_itemtypes' => sub {
Link Here
|
51 |
|
54 |
|
52 |
# Change the rules |
55 |
# Change the rules |
53 |
$rule2->itemtype('*')->store; |
56 |
$rule2->itemtype('*')->store; |
54 |
$Koha::IssuingRules::last_article_requestable_guesses = {}; |
57 |
$cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); |
55 |
$res = Koha::IssuingRules->guess_article_requestable_itemtypes; |
58 |
$res = Koha::IssuingRules->guess_article_requestable_itemtypes; |
56 |
is( $res->{'*'}, 1, 'Item type * seems permitted' ); |
59 |
is( $res->{'*'}, 1, 'Item type * seems permitted' ); |
57 |
is( $res->{$itype1->itemtype}, 1, 'Item type 1 seems permitted' ); |
60 |
is( $res->{$itype1->itemtype}, 1, 'Item type 1 seems permitted' ); |
Lines 61-67
subtest 'guess_article_requestable_itemtypes' => sub {
Link Here
|
61 |
is( $res->{$itype1->itemtype}, 1, 'Item type 1 seems permitted' ); |
64 |
is( $res->{$itype1->itemtype}, 1, 'Item type 1 seems permitted' ); |
62 |
is( $res->{$itype2->itemtype}, undef, 'Item type 2 seems not permitted' ); |
65 |
is( $res->{$itype2->itemtype}, undef, 'Item type 2 seems not permitted' ); |
63 |
|
66 |
|
64 |
$Koha::IssuingRules::last_article_requestable_guesses = {}; |
67 |
$cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); |
65 |
}; |
68 |
}; |
66 |
|
69 |
|
67 |
$schema->storage->txn_rollback; |
70 |
$schema->storage->txn_rollback; |
68 |
- |
|
|