+
+subtest "Test patron's own holds do not count towards HighHolds count" => sub {
+
+ plan tests => 2;
+
+ my $item = $builder->build_sample_item();
+ my $item2 = $builder->build_sample_item({ biblionumber => $item->biblionumber });
+ my $item3 = $builder->build_sample_item({ biblionumber => $item->biblionumber });
+
+ my $patron = $builder->build_object({
+ class => 'Koha::Patrons',
+ value => {
+ branchcode => $item->homebranch
+ }
+ });
+ my $hold = $builder->build_object({
+ class => 'Koha::Holds',
+ value => {
+ biblionumber => $item->biblionumber,
+ borrowernumber => $patron->id,
+ suspend => 0,
+ found => undef
+ }
+ });
+
+ Koha::CirculationRules->set_rules(
+ {
+ branchcode => $item->homebranch,
+ categorycode => undef,
+ itemtype => $item->itype,
+ rules => {
+ issuelength => '14',
+ lengthunit => 'days',
+ reservesallowed => '99',
+ holds_per_record => '1',
+ }
+ }
+ );
+
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHolds', 1 );
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsDuration', 1 );
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 1 );
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'static' );
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
+
+ my $data = C4::Circulation::checkHighHolds( $item , $patron );
+ ok( !$data->{exceeded}, "Patron's hold on the record does not limit their own circulation if static decrease");
+ t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'dynamic' );
+ # 3 items on record, patron has 1 hold
+ $data = C4::Circulation::checkHighHolds( $item, $patron );
+ ok( !$data->{exceeded}, "Patron's hold on the record does not limit their own circulation if dynamic decrease");
+
+};
+