Lines 318-335
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 => 3; |
321 |
plan tests => 5; |
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; # This does not work |
329 |
->next; |
330 |
ok( $deleted_patron->updated_on, 'The ->updated_on method should return something' ); |
330 |
isnt( $deleted_patron->{updated_on}, $retrieved_patron->{updated_on}, 'Koha::Patron->move_to_deleted should have correctly updated the updated_on column'); |
331 |
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' ); |
331 |
$deleted_patron->{updated_on} = $originally_updated_on; #reset for simplicity in comparing all other fields |
332 |
isnt( $deleted_patron->updated_on, $retrieved_patron->updated_on, 'Koha::Patron->move_to_deleted should have correctly updated the updated_on column'); |
332 |
is_deeply( $deleted_patron, $patron, 'Koha::Patron->move_to_deleted should have correctly moved the patron to the deleted table' ); |
333 |
$deleted_patron->updated_on($originally_updated_on); #reset for simplicity in comparing all other fields |
|
|
334 |
is_deeply( { $deleted_patron->get_columns }, $patron, 'Koha::Patron->move_to_deleted should have correctly moved the patron to the deleted table' ); |
333 |
$retrieved_patron->delete( $patron->{borrowernumber} ); # Cleanup |
335 |
$retrieved_patron->delete( $patron->{borrowernumber} ); # Cleanup |
334 |
}; |
336 |
}; |
335 |
|
337 |
|
336 |
- |
|
|