Lines 318-337
subtest 'renew_account' => sub {
Link Here
|
318 |
}; |
318 |
}; |
319 |
|
319 |
|
320 |
subtest "move_to_deleted" => sub { |
320 |
subtest "move_to_deleted" => sub { |
321 |
plan tests => 5; |
321 |
plan tests => 6; |
322 |
my $originally_updated_on = '2016-01-01 12:12:12'; |
322 |
my $originally_updated_on = '2016-01-01 12:12:12'; |
323 |
my $patron = $builder->build( { source => 'Borrower',value => { updated_on => $originally_updated_on } } ); |
323 |
my $patron = $builder->build( { source => 'Borrower',value => { updated_on => $originally_updated_on } } ); |
324 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
324 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
325 |
is( ref( $retrieved_patron->move_to_deleted ), 'Koha::Schema::Result::Deletedborrower', 'Koha::Patron->move_to_deleted should return the Deleted patron' ) |
325 |
my $deleted_patron = $retrieved_patron->move_to_deleted; |
|
|
326 |
is( ref( $deleted_patron ), 'Koha::Schema::Result::Deletedborrower', 'Koha::Patron->move_to_deleted should return the Deleted patron' ) |
326 |
; # FIXME This should be Koha::Deleted::Patron |
327 |
; # FIXME This should be Koha::Deleted::Patron |
327 |
my $deleted_patron = $schema->resultset('Deletedborrower') |
328 |
|
328 |
->search( { borrowernumber => $patron->{borrowernumber} }, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ) |
329 |
$deleted_patron->discard_changes; |
329 |
->next; |
330 |
|
330 |
ok( $retrieved_patron->updated_on, 'updated_on should be set for borrowers table' ); |
331 |
ok( $retrieved_patron->updated_on, 'updated_on should be set for borrowers table' ); |
331 |
ok( $deleted_patron->{updated_on}, 'updated_on should be set for deleted_borrowers table' ); |
332 |
ok( $deleted_patron->updated_on, 'updated_on should be set for deleted_borrowers table' ); |
332 |
isnt( $deleted_patron->{updated_on}, $retrieved_patron->updated_on, 'Koha::Patron->move_to_deleted should have correctly updated the updated_on column'); |
333 |
is( dt_from_string($deleted_patron->updated_on)->truncate( to => 'day' ), dt_from_string->truncate( to => 'day' ), 'The updated_on value for the deleted patron should be today' ); |
333 |
$deleted_patron->{updated_on} = $originally_updated_on; #reset for simplicity in comparing all other fields |
334 |
isnt( $deleted_patron->updated_on, $retrieved_patron->updated_on, 'Koha::Patron->move_to_deleted should have correctly updated the updated_on column'); |
334 |
is_deeply( $deleted_patron, $patron, 'Koha::Patron->move_to_deleted should have correctly moved the patron to the deleted table' ); |
335 |
$deleted_patron->updated_on($originally_updated_on); #reset for simplicity in comparing all other fields |
|
|
336 |
is_deeply( { $deleted_patron->get_columns }, $patron, 'Koha::Patron->move_to_deleted should have correctly moved the patron to the deleted table' ); |
335 |
$retrieved_patron->delete( $patron->{borrowernumber} ); # Cleanup |
337 |
$retrieved_patron->delete( $patron->{borrowernumber} ); # Cleanup |
336 |
}; |
338 |
}; |
337 |
|
339 |
|
338 |
- |
|
|