Lines 184-211
$context->mock(
Link Here
|
184 |
}; |
184 |
}; |
185 |
} |
185 |
} |
186 |
); |
186 |
); |
187 |
# Test Koha::Statistic->invalid_patron |
187 |
# Test Koha::Statistic->log_invalid_patron |
188 |
$dbh->do(q{DELETE FROM statistics}); |
188 |
$dbh->do(q{DELETE FROM statistics}); |
189 |
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 ); |
189 |
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 ); |
190 |
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } ); |
190 |
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } ); |
191 |
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' ); |
191 |
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' ); |
192 |
|
192 |
|
193 |
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 ); |
193 |
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 ); |
194 |
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } ); |
194 |
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } ); |
195 |
my $stat = Koha::Statistics->search()->next(); |
195 |
my $stat = Koha::Statistics->search()->next(); |
196 |
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' ); |
196 |
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' ); |
197 |
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' ); |
197 |
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' ); |
198 |
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' ); |
198 |
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' ); |
199 |
is( $stat->branch, $branchcode, 'Branchcode is set correctly' ); |
199 |
is( $stat->branch, $branchcode, 'Branchcode is set correctly' ); |
200 |
|
200 |
|
201 |
# Test Koha::Statistic->invalid_item |
201 |
# Test Koha::Statistic->log_invalid_item |
202 |
$dbh->do(q{DELETE FROM statistics}); |
202 |
$dbh->do(q{DELETE FROM statistics}); |
203 |
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 ); |
203 |
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 ); |
204 |
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } ); |
204 |
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } ); |
205 |
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' ); |
205 |
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' ); |
206 |
|
206 |
|
207 |
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 ); |
207 |
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 ); |
208 |
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } ); |
208 |
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } ); |
209 |
$stat = Koha::Statistics->search()->next(); |
209 |
$stat = Koha::Statistics->search()->next(); |
210 |
is( $stat->type, 'invalid_item', 'Type set to invalid_item' ); |
210 |
is( $stat->type, 'invalid_item', 'Type set to invalid_item' ); |
211 |
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' ); |
211 |
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' ); |
212 |
- |
|
|