|
Lines 45-50
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 45 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
45 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
| 46 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
46 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
| 47 |
|
47 |
|
|
|
48 |
### Mock Letters |
| 49 |
my $mocked_letters = Test::MockModule->new('C4::Letters'); |
| 50 |
$mocked_letters->mock( |
| 51 |
'GetPreparedLetter', |
| 52 |
sub { |
| 53 |
return 1; |
| 54 |
} |
| 55 |
); |
| 56 |
my $letter_enqueued; |
| 57 |
$mocked_letters->mock( |
| 58 |
'EnqueueLetter', |
| 59 |
sub { |
| 60 |
$letter_enqueued = 1; |
| 61 |
|
| 62 |
# return a 'message_id' |
| 63 |
return 42; |
| 64 |
} |
| 65 |
); |
| 66 |
$mocked_letters->mock( |
| 67 |
'SendQueuedMessages', |
| 68 |
sub { |
| 69 |
my $params = shift; |
| 70 |
return 1; |
| 71 |
} |
| 72 |
); |
| 73 |
|
| 48 |
subtest 'list() tests' => sub { |
74 |
subtest 'list() tests' => sub { |
| 49 |
|
75 |
|
| 50 |
plan tests => 3; |
76 |
plan tests => 3; |
|
Lines 382-387
subtest 'add() tests' => sub {
Link Here
|
| 382 |
# Set a date-time field |
408 |
# Set a date-time field |
| 383 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
409 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
| 384 |
|
410 |
|
|
|
411 |
$letter_enqueued = 0; |
| 385 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) |
412 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) |
| 386 |
->status_is(201, 'Patron created successfully') |
413 |
->status_is(201, 'Patron created successfully') |
| 387 |
->header_like( |
414 |
->header_like( |
|
Lines 396-402
subtest 'add() tests' => sub {
Link Here
|
| 396 |
->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); |
423 |
->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); |
| 397 |
|
424 |
|
| 398 |
my $p = Koha::Patrons->find( { cardnumber => $newpatron->{cardnumber} } ); |
425 |
my $p = Koha::Patrons->find( { cardnumber => $newpatron->{cardnumber} } ); |
| 399 |
is( Koha::Notice::Messages->search({ borrowernumber => $p->borrowernumber })->count, 1 , "Patron got welcome notice" ); |
426 |
is( $letter_enqueued, 1 , "Patron got welcome notice" ); |
| 400 |
|
427 |
|
| 401 |
$newpatron->{userid} = undef; # force regeneration |
428 |
$newpatron->{userid} = undef; # force regeneration |
| 402 |
warning_like { |
429 |
warning_like { |
| 403 |
- |
|
|