Lines 54-59
my $policy = Koha::CurbsidePickupPolicy->new(
Link Here
|
54 |
{ |
54 |
{ |
55 |
branchcode => $library->branchcode, |
55 |
branchcode => $library->branchcode, |
56 |
enabled => 1, |
56 |
enabled => 1, |
|
|
57 |
enable_waiting_holds_only => 0, |
57 |
pickup_interval => 30, |
58 |
pickup_interval => 30, |
58 |
patrons_per_interval => 2, |
59 |
patrons_per_interval => 2, |
59 |
patron_scheduled_pickup => 1 |
60 |
patron_scheduled_pickup => 1 |
Lines 63-68
my $policy_disabled = Koha::CurbsidePickupPolicy->new(
Link Here
|
63 |
{ |
64 |
{ |
64 |
branchcode => $library_disabled->branchcode, |
65 |
branchcode => $library_disabled->branchcode, |
65 |
enabled => 0, |
66 |
enabled => 0, |
|
|
67 |
enable_waiting_holds_only => 0, |
66 |
pickup_interval => 30, |
68 |
pickup_interval => 30, |
67 |
patrons_per_interval => 2, |
69 |
patrons_per_interval => 2, |
68 |
patron_scheduled_pickup => 1 |
70 |
patron_scheduled_pickup => 1 |
Lines 75-106
$policy->add_opening_slot('1-12:00-18:00');
Link Here
|
75 |
my $today = dt_from_string; |
77 |
my $today = dt_from_string; |
76 |
|
78 |
|
77 |
subtest 'Create a pickup' => sub { |
79 |
subtest 'Create a pickup' => sub { |
78 |
plan tests => 5; |
80 |
plan tests => 7; |
79 |
|
81 |
|
80 |
# Day and datetime are ok |
82 |
# Day and datetime are ok |
81 |
my $next_monday = |
83 |
my $next_monday = |
82 |
$today->clone->add( days => ( 1 - $today->day_of_week ) % 7 ); |
84 |
$today->clone->add( days => ( 1 - $today->day_of_week ) % 7 ); |
83 |
my $schedule_dt = |
85 |
my $schedule_dt = |
84 |
$next_monday->set_hour(15)->set_minute(00)->set_second(00); |
86 |
$next_monday->set_hour(15)->set_minute(00)->set_second(00); |
85 |
my $cp = Koha::CurbsidePickup->new( |
87 |
my $params = |
86 |
{ |
88 |
{ |
87 |
branchcode => $library->branchcode, |
89 |
branchcode => $library->branchcode, |
88 |
borrowernumber => $patron->borrowernumber, |
90 |
borrowernumber => $patron->borrowernumber, |
89 |
scheduled_pickup_datetime => $schedule_dt, |
91 |
scheduled_pickup_datetime => $schedule_dt, |
90 |
notes => 'just a note' |
92 |
notes => 'just a note' |
91 |
} |
93 |
}; |
92 |
)->store; |
94 |
|
|
|
95 |
throws_ok { |
96 |
Koha::CurbsidePickup->new({%$params, branchcode => $library_disabled->branchcode})->store; |
97 |
} |
98 |
'Koha::Exceptions::CubsidePickup::NotEnabled', |
99 |
'Cannot create pickup if the policy does not allow it'; |
100 |
|
101 |
$policy->enable_waiting_holds_only(1)->store; |
102 |
throws_ok { |
103 |
Koha::CurbsidePickup->new($params)->store; |
104 |
} |
105 |
'Koha::Exceptions::CubsidePickup::NoWaitingHolds', |
106 |
'Cannot create pickup for a patron without waiting hold if flag is set'; |
107 |
|
108 |
$policy->enable_waiting_holds_only(0)->store; |
109 |
my $cp = Koha::CurbsidePickup->new($params)->store; |
93 |
is( $cp->status, 'to-be-staged' ); |
110 |
is( $cp->status, 'to-be-staged' ); |
94 |
|
111 |
|
95 |
throws_ok { |
112 |
throws_ok { |
96 |
Koha::CurbsidePickup->new( |
113 |
Koha::CurbsidePickup->new($params)->store |
97 |
{ |
|
|
98 |
branchcode => $library->branchcode, |
99 |
borrowernumber => $patron->borrowernumber, |
100 |
scheduled_pickup_datetime => $schedule_dt, |
101 |
notes => 'just a note' |
102 |
} |
103 |
)->store |
104 |
} |
114 |
} |
105 |
'Koha::Exceptions::CubsidePickup::TooManyPickups', |
115 |
'Koha::Exceptions::CubsidePickup::TooManyPickups', |
106 |
'Cannot create 2 pickups for the same patron'; |
116 |
'Cannot create 2 pickups for the same patron'; |
Lines 112-125
subtest 'Create a pickup' => sub {
Link Here
|
112 |
$today->clone->add( days => ( 2 - $today->day_of_week ) % 7 ); |
122 |
$today->clone->add( days => ( 2 - $today->day_of_week ) % 7 ); |
113 |
$schedule_dt = $next_tuesday->set_hour(15)->set_minute(00)->set_second(00); |
123 |
$schedule_dt = $next_tuesday->set_hour(15)->set_minute(00)->set_second(00); |
114 |
throws_ok { |
124 |
throws_ok { |
115 |
Koha::CurbsidePickup->new( |
125 |
Koha::CurbsidePickup->new({%$params, scheduled_pickup_datetime => $schedule_dt})->store; |
116 |
{ |
|
|
117 |
branchcode => $library->branchcode, |
118 |
borrowernumber => $patron->borrowernumber, |
119 |
scheduled_pickup_datetime => $schedule_dt, |
120 |
notes => 'just a note' |
121 |
} |
122 |
)->store |
123 |
} |
126 |
} |
124 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
127 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
125 |
'Cannot create a pickup on a day without opening slots defined'; |
128 |
'Cannot create a pickup on a day without opening slots defined'; |
Lines 127-140
subtest 'Create a pickup' => sub {
Link Here
|
127 |
# Day ok but datetime not ok |
130 |
# Day ok but datetime not ok |
128 |
$schedule_dt = $next_monday->set_hour(19)->set_minute(00)->set_second(00); |
131 |
$schedule_dt = $next_monday->set_hour(19)->set_minute(00)->set_second(00); |
129 |
throws_ok { |
132 |
throws_ok { |
130 |
Koha::CurbsidePickup->new( |
133 |
Koha::CurbsidePickup->new({%$params, scheduled_pickup_datetime => $schedule_dt})->store; |
131 |
{ |
|
|
132 |
branchcode => $library->branchcode, |
133 |
borrowernumber => $patron->borrowernumber, |
134 |
scheduled_pickup_datetime => $schedule_dt, |
135 |
notes => 'just a note' |
136 |
} |
137 |
)->store |
138 |
} |
134 |
} |
139 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
135 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
140 |
'Cannot create a pickup on a time without opening slots defined'; |
136 |
'Cannot create a pickup on a time without opening slots defined'; |
Lines 142-155
subtest 'Create a pickup' => sub {
Link Here
|
142 |
# Day ok, datetime inside the opening slot, but wrong (15:15 for instance) |
138 |
# Day ok, datetime inside the opening slot, but wrong (15:15 for instance) |
143 |
$schedule_dt = $next_monday->set_hour(15)->set_minute(15)->set_second(00); |
139 |
$schedule_dt = $next_monday->set_hour(15)->set_minute(15)->set_second(00); |
144 |
throws_ok { |
140 |
throws_ok { |
145 |
Koha::CurbsidePickup->new( |
141 |
Koha::CurbsidePickup->new({%$params, scheduled_pickup_datetime => $schedule_dt})->store; |
146 |
{ |
|
|
147 |
branchcode => $library->branchcode, |
148 |
borrowernumber => $patron->borrowernumber, |
149 |
scheduled_pickup_datetime => $schedule_dt, |
150 |
notes => 'just a note' |
151 |
} |
152 |
)->store |
153 |
} |
142 |
} |
154 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
143 |
'Koha::Exceptions::CubsidePickup::NoMatchingSlots', |
155 |
'Cannot create a pickup on a time that is not matching the start of an interval'; |
144 |
'Cannot create a pickup on a time that is not matching the start of an interval'; |
156 |
- |
|
|