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

(-)a/t/db_dependent/Koha/Patron/Categories.t (-2 / +26 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 10;
22
use Test::More tests => 11;
23
23
24
use C4::Context;
24
use C4::Context;
25
use Koha::Database;
25
use Koha::Database;
Lines 115-119 my $new_category_4 = Koha::Patron::Category->new( Link Here
115
)->store;
115
)->store;
116
is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'upperagelimit and dateofbirthrequired should have a default value if empty string is passed' );
116
is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'upperagelimit and dateofbirthrequired should have a default value if empty string is passed' );
117
117
118
subtest 'can_make_suggestions' => sub {
119
    plan tests => 5;
120
    t::lib::Mocks::mock_preference('suggestion', 0);
121
    my $category = Koha::Patron::Category->new({
122
        categorycode => 'the_cat',
123
        category_type => 'A',
124
        description => 'thecatdesc',
125
        enrolementperiod => undef
126
    })->store;
127
    is ( $category->can_make_suggestions, undef, 'With suggestion syspref disabled and suggestionPatronCategoryExceptions syspref empty then Koha::Patron::Category->can_make_suggestions() returns undef' );
128
129
    t::lib::Mocks::mock_preference('suggestion', 1);
130
    is( $category->can_make_suggestions, 1, 'With suggestion syspref enabled and suggestionPatronsCategoryExceptions syspref empty then Koha::Patron::Category->can_make_suggestions() returns 1' );
131
132
    t::lib::Mocks::mock_preference('suggestionPatronCategoryExceptions', 'the_cat');
133
    is( $category->can_make_suggestions, undef, 'With suggestion syspref enabled and suggestionPatronCategoryExceptions syspref = "the_cat" then Koha::Patron::Category->can_make_suggestions() returns undef' );
134
135
    t::lib::Mocks::mock_preference('suggestionPatronCategoryExceptions', 'mycatcodeW');
136
    is( $category->can_make_suggestions, 1, 'With suggestion syspref enabled and suggestionPatronCategoryExceptions syspref = "mycatcodeW" then Koha::Patron::Category->can_make_suggestions returns 1' );
137
138
    t::lib::Mocks::mock_preference('suggestion', 0);
139
    is( $category->can_make_suggestions, undef, 'With suggestion syspref disabled and suggestionPatronCategoryExceptions syspref = "mycatcodeW" then Koha::Patron::Category->can_make_suggestions returns undef' );
140
    $category->delete;
141
};
142
118
$schema->storage->txn_rollback;
143
$schema->storage->txn_rollback;
119
144
120
- 

Return to bug 31333