Lines 374-385
subtest 'pending_count() and pending() tests' => sub {
Link Here
|
374 |
}; |
374 |
}; |
375 |
|
375 |
|
376 |
subtest 'dateofbirth tests' => sub { |
376 |
subtest 'dateofbirth tests' => sub { |
377 |
plan tests => 3; |
377 |
plan tests => 7; |
378 |
|
378 |
|
379 |
$schema->storage->txn_begin; |
379 |
$schema->storage->txn_begin; |
380 |
|
380 |
|
381 |
# Cleaning the field |
381 |
# Cleaning the field |
382 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { dateofbirth => '1980-01-01' } } ); |
382 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { dateofbirth => '1980-01-01', surname => 'a_surname' } } ); |
383 |
my $patron_modification = Koha::Patron::Modification->new( { borrowernumber => $patron->borrowernumber, dateofbirth => undef } |
383 |
my $patron_modification = Koha::Patron::Modification->new( { borrowernumber => $patron->borrowernumber, dateofbirth => undef } |
384 |
)->store; |
384 |
)->store; |
385 |
$patron_modification->approve; |
385 |
$patron_modification->approve; |
Lines 397-413
subtest 'dateofbirth tests' => sub {
Link Here
|
397 |
|
397 |
|
398 |
$patron->discard_changes; |
398 |
$patron->discard_changes; |
399 |
is( $patron->dateofbirth, '1980-02-02', 'dateofbirth must a been set' ); |
399 |
is( $patron->dateofbirth, '1980-02-02', 'dateofbirth must a been set' ); |
|
|
400 |
is( $patron->surname, 'a_surname', 'surname must not be updated' ); |
400 |
|
401 |
|
401 |
# FIXME ->approve must have been removed it, but it did not. There may be an hidden bug here. |
402 |
# FIXME ->approve must have been removed it, but it did not. There may be an hidden bug here. |
402 |
Koha::Patron::Modifications->search({ borrowernumber => $patron->borrowernumber })->delete; |
403 |
Koha::Patron::Modifications->search({ borrowernumber => $patron->borrowernumber })->delete; |
403 |
|
404 |
|
404 |
# Modifying a dateofbirth |
405 |
# Modifying a dateofbirth |
405 |
$patron_modification = Koha::Patron::Modification->new( { borrowernumber => $patron->borrowernumber, dateofbirth => '1980-03-03' } |
406 |
$patron_modification = Koha::Patron::Modification->new( { borrowernumber => $patron->borrowernumber, dateofbirth => '1980-03-03', surname => undef } |
406 |
)->store; |
407 |
)->store; |
407 |
$patron_modification->approve; |
408 |
$patron_modification->approve; |
408 |
|
409 |
|
409 |
$patron->discard_changes; |
410 |
$patron->discard_changes; |
410 |
is( $patron->dateofbirth, '1980-03-03', 'dateofbirth must a been updated' ); |
411 |
is( $patron->dateofbirth, '1980-03-03', 'dateofbirth must a been updated' ); |
|
|
412 |
is( $patron->surname, 'a_surname', 'surname must not be updated' ); |
413 |
|
414 |
# FIXME ->approve must have been removed it, but it did not. There may be an hidden bug here. |
415 |
Koha::Patron::Modifications->search({ borrowernumber => $patron->borrowernumber })->delete; |
416 |
|
417 |
# Modifying something else |
418 |
$patron_modification = Koha::Patron::Modification->new( { borrowernumber => $patron->borrowernumber, surname => 'another_surname', dateofbirth => undef } |
419 |
)->store; |
420 |
$patron_modification->approve; |
421 |
|
422 |
$patron->discard_changes; |
423 |
is( $patron->surname, 'another_surname', 'surname must be updated' ); |
424 |
is( $patron->dateofbirth, '1980-03-03', 'dateofbirth should not have been updated if not needed' ); |
411 |
|
425 |
|
412 |
$schema->storage->txn_rollback; |
426 |
$schema->storage->txn_rollback; |
413 |
}; |
427 |
}; |
414 |
- |
|
|