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

(-)a/t/db_dependent/api/v1/checkouts.t (-2 / +21 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 53;
20
use Test::More tests => 67;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Mojo;
22
use Test::Mojo;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 74-79 $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$notexisting_patron Link Here
74
my $item1 = $builder->build_sample_item;
74
my $item1 = $builder->build_sample_item;
75
my $item2 = $builder->build_sample_item;
75
my $item2 = $builder->build_sample_item;
76
my $item3 = $builder->build_sample_item;
76
my $item3 = $builder->build_sample_item;
77
my $item4 = $builder->build_sample_item;
77
78
78
my $date_due = DateTime->now->add(weeks => 2);
79
my $date_due = DateTime->now->add(weeks => 2);
79
my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
80
my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
Lines 82-87 my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $dat Link Here
82
my $date_due2 = Koha::DateUtils::dt_from_string( $issue2->date_due );
83
my $date_due2 = Koha::DateUtils::dt_from_string( $issue2->date_due );
83
my $issue3 = C4::Circulation::AddIssue($librarian->unblessed, $item3->barcode, $date_due);
84
my $issue3 = C4::Circulation::AddIssue($librarian->unblessed, $item3->barcode, $date_due);
84
my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due );
85
my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due );
86
my $issue4 = C4::Circulation::AddIssue($patron->unblessed, $item4->barcode);
87
C4::Circulation::AddReturn($item4->barcode, $branchcode);
85
88
86
$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id" )
89
$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id" )
87
  ->status_is(200)
90
  ->status_is(200)
Lines 93-98 $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id" ) Link Here
93
  ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) )
96
  ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) )
94
  ->json_hasnt('/2');
97
  ->json_hasnt('/2');
95
98
99
# Test checked_in parameter, zero means, the response is same as without it
100
$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id&checked_in=0" )
101
  ->status_is(200)
102
  ->json_is('/0/patron_id' => $patron_id)
103
  ->json_is('/0/item_id' => $item1->itemnumber)
104
  ->json_is('/0/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) )
105
  ->json_is('/1/patron_id' => $patron_id)
106
  ->json_is('/1/item_id' => $item2->itemnumber)
107
  ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) )
108
  ->json_hasnt('/2');
109
110
# Test checked_in parameter, one measn, the checked in checkout is in the response too
111
$t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id&checked_in=1" )
112
  ->status_is(200)
113
  ->json_is('/0/patron_id' => $patron_id)
114
  ->json_is('/0/item_id' => $item4->itemnumber)
115
  ->json_hasnt('/1');
96
116
97
$t->get_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts/" . $issue3->issue_id )
117
$t->get_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts/" . $issue3->issue_id )
98
  ->status_is(403)
118
  ->status_is(403)
99
- 

Return to bug 17005