Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 1; |
22 |
use Test::More tests => 2; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
Lines 86-88
subtest 'effective_reset_password() tests' => sub {
Link Here
|
86 |
$schema->storage->txn_rollback; |
86 |
$schema->storage->txn_rollback; |
87 |
}; |
87 |
}; |
88 |
}; |
88 |
}; |
89 |
- |
89 |
|
|
|
90 |
subtest 'effective_change_password() tests' => sub { |
91 |
|
92 |
plan tests => 2; |
93 |
|
94 |
subtest 'specific overrides global' => sub { |
95 |
|
96 |
plan tests => 4; |
97 |
|
98 |
$schema->storage->txn_begin; |
99 |
|
100 |
my $category = $builder->build_object({ |
101 |
class => 'Koha::Patron::Categories', |
102 |
value => { |
103 |
change_password => 1 |
104 |
} |
105 |
}); |
106 |
|
107 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); |
108 |
ok( $category->effective_change_password, 'OpacPasswordChange unset, but category has the flag set to 1' ); |
109 |
|
110 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); |
111 |
ok( $category->effective_change_password, 'OpacPasswordChange set and category has the flag set to 1' ); |
112 |
|
113 |
# disable |
114 |
$category->change_password( 0 )->store->discard_changes; |
115 |
|
116 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); |
117 |
ok( !$category->effective_change_password, 'OpacPasswordChange unset, but category has the flag set to 0' ); |
118 |
|
119 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); |
120 |
ok( !$category->effective_change_password, 'OpacPasswordChange set and category has the flag set to 0' ); |
121 |
|
122 |
$schema->storage->txn_rollback; |
123 |
}; |
124 |
|
125 |
subtest 'no specific rule, global applies' => sub { |
126 |
|
127 |
plan tests => 2; |
128 |
|
129 |
$schema->storage->txn_begin; |
130 |
|
131 |
my $category = $builder->build_object({ |
132 |
class => 'Koha::Patron::Categories', |
133 |
value => { |
134 |
change_password => undef |
135 |
} |
136 |
}); |
137 |
|
138 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 0 ); |
139 |
ok( !$category->effective_change_password, 'OpacPasswordChange set to 0 used' ); |
140 |
|
141 |
t::lib::Mocks::mock_preference( 'OpacPasswordChange', 1 ); |
142 |
ok( $category->effective_change_password, 'OpacPasswordChange set to 1 used' ); |
143 |
|
144 |
$schema->storage->txn_rollback; |
145 |
}; |
146 |
}; |