View | Details | Raw Unified | Return to bug 17492
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Patrons.t (-10 / +9 lines)
Lines 559-589 subtest 'is_category_valid' => sub { Link Here
559
    is( $patron->is_category_valid, 1, 'Patron with no dateofbirth is always valid for any category');
559
    is( $patron->is_category_valid, 1, 'Patron with no dateofbirth is always valid for any category');
560
560
561
    $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) );
561
    $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) );
562
    is( $patron->is_category_valid, 0, 'Patron is 12, so his age is above allowed range 5-10 years');
562
    is( $patron->is_category_valid, 0, 'Patron is 12, so the age is above allowed range 5-10 years');
563
563
564
    $patron->dateofbirth( $today->clone->add( years => -3, months => -6, days => -1 ) );
564
    $patron->dateofbirth( $today->clone->add( years => -3, months => -6, days => -1 ) );
565
    is( $patron->is_category_valid, 0, 'Patron is 3, so his age is below allowed range 5-10 years');
565
    is( $patron->is_category_valid, 0, 'Patron is 3, so the age is below allowed range 5-10 years');
566
566
567
    $patron->dateofbirth( $today->clone->add( years => -7, months => -6, days => -1 ) );
567
    $patron->dateofbirth( $today->clone->add( years => -7, months => -6, days => -1 ) );
568
    is( $patron->is_category_valid, 1, 'Patron is 7, so his age perfectly suits allowed range 5-10 years');
568
    is( $patron->is_category_valid, 1, 'Patron is 7, so the age perfectly suits allowed range 5-10 years');
569
569
570
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 0 ) );
570
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 0 ) );
571
    is( $patron->is_category_valid, 1, 'Patron celebrates the 5th birthday today, so he is allowed for this category');
571
    is( $patron->is_category_valid, 1, 'Patron celebrates the 5th birthday today, so the age is allowed for this category');
572
572
573
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 1 ) );
573
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 1 ) );
574
    is( $patron->is_category_valid, 0, 'Patron will celebrate the 5th birthday tomorrow, so he is NOT allowed for this category');
574
    is( $patron->is_category_valid, 0, 'Patron will celebrate the 5th birthday tomorrow, so the age is NOT allowed for this category');
575
575
576
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => -1 ) );
576
    $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => -1 ) );
577
    is( $patron->is_category_valid, 1, 'Patron celebrated the 5th birthday yesterday, so he is allowed for this category');
577
    is( $patron->is_category_valid, 1, 'Patron celebrated the 5th birthday yesterday, so the age is allowed for this category');
578
578
579
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 0 ) );
579
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 0 ) );
580
    is( $patron->is_category_valid, 0, 'Patron celebrate the 11th birthday today, so he is NOT allowed for this category');
580
    is( $patron->is_category_valid, 0, 'Patron celebrate the 11th birthday today, so the age is NOT allowed for this category');
581
581
582
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 1 ) );
582
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 1 ) );
583
    is( $patron->is_category_valid, 1, 'Patron will celebrate the 11th birthday tomorrow, so he is allowed for this category');
583
    is( $patron->is_category_valid, 1, 'Patron will celebrate the 11th birthday tomorrow, so the age is allowed for this category');
584
584
585
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => -1 ) );
585
    $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => -1 ) );
586
    is( $patron->is_category_valid, 0, 'Patron celebrated the 11th birthday yesterday, so he is NOT allowed for this category');
586
    is( $patron->is_category_valid, 0, 'Patron celebrated the 11th birthday yesterday, so the age is NOT allowed for this category');
587
587
588
    $patron->delete;
588
    $patron->delete;
589
    $category->delete;
589
    $category->delete;
590
- 

Return to bug 17492