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( 'GetPreparedLetter', sub { |
51 |
return 1; |
52 |
}); |
53 |
my $letter_enqueued; |
54 |
$mocked_letters->mock( 'EnqueueLetter', sub { |
55 |
$letter_enqueued = 1; |
56 |
# return a 'message_id' |
57 |
return 42; |
58 |
}); |
59 |
$mocked_letters->mock( 'SendQueuedMessages', sub { |
60 |
my $params = shift; |
61 |
return 1; |
62 |
}); |
63 |
|
48 |
subtest 'list() tests' => sub { |
64 |
subtest 'list() tests' => sub { |
49 |
|
65 |
|
50 |
plan tests => 3; |
66 |
plan tests => 3; |
Lines 382-387
subtest 'add() tests' => sub {
Link Here
|
382 |
# Set a date-time field |
398 |
# Set a date-time field |
383 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
399 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
384 |
|
400 |
|
|
|
401 |
$letter_enqueued = 0; |
385 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) |
402 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) |
386 |
->status_is(201, 'Patron created successfully') |
403 |
->status_is(201, 'Patron created successfully') |
387 |
->header_like( |
404 |
->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)' ); |
413 |
->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); |
397 |
|
414 |
|
398 |
my $p = Koha::Patrons->find( { cardnumber => $newpatron->{cardnumber} } ); |
415 |
my $p = Koha::Patrons->find( { cardnumber => $newpatron->{cardnumber} } ); |
399 |
is( Koha::Notice::Messages->search({ borrowernumber => $p->borrowernumber })->count, 1 , "Patron got welcome notice" ); |
416 |
is( $letter_enqueued, 1 , "Patron got welcome notice" ); |
400 |
|
417 |
|
401 |
$newpatron->{userid} = undef; # force regeneration |
418 |
$newpatron->{userid} = undef; # force regeneration |
402 |
warning_like { |
419 |
warning_like { |
403 |
- |
|
|