Bug 28873

Summary: Incorrect age displayed in db_dependent/Koha/Patrons.t
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: Test SuiteAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, kyle, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes age tests in t/db_dependent/Koha/Patrons.t so that the correct ages are calculated and displayed. It also adds the category code 'AGE_5_10' in messages to display age limits.
Version(s) released in:
21.11.00,21.05.03,20.11.10
Attachments: Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t
Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t
Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t

Description Fridolin Somers 2021-08-17 20:18:01 UTC
In test suite db_dependent/Koha/Patrons.t actually shows :

# Subtest: is_valid_age
    1..10
    ok 1 - Patron with no dateofbirth is always valid for any category
    ok 2 - Today=2020-02-28, dob=2015-03-01, is 5, should be valid=0
    ok 3 - Today=2020-02-28, dob=2015-02-27, is 5, should be valid=1
    ok 4 - Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0
    ok 5 - Today=2020-02-28, dob=2015-02-28, is 7, should be valid=1
    ok 6 - Today=2020-02-28, dob=2009-02-27, is 11, should be valid=0
    ok 7 - Today=2020-02-28, dob=2016-08-27, is 3, should be valid=0
    ok 8 - Today=2020-02-28, dob=2009-03-01, is 11, should be valid=1
    ok 9 - Today=2020-02-28, dob=2007-08-27, is 12, should be valid=0
    ok 10 - Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1

Some ages are incorrect :

1) dob=2009-03-01, is 11
=> it is age 10
so valid=1 in category 5 to 10

2) dob=2015-03-01, is 5
=> it is age 4
so valid=0 in category 5 to 10

3) dob=2015-02-28, is 7
=> this date of birth is already tested
I suppose here dob is wrong, age wanted is 7 in the middle of age restrictions.
so dob=2013-02-28
Comment 1 Fridolin Somers 2021-08-17 20:22:57 UTC
Created attachment 123914 [details] [review]
Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t

In test suite db_dependent/Koha/Patrons.t actually shows :

    1..10
    ok 1 - Patron with no dateofbirth is always valid for any category
    ok 2 - Today=2020-02-28, dob=2015-03-01, is 5, should be valid=0
    ok 3 - Today=2020-02-28, dob=2015-02-27, is 5, should be valid=1
    ok 4 - Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0
    ok 5 - Today=2020-02-28, dob=2015-02-28, is 7, should be valid=1
    ok 6 - Today=2020-02-28, dob=2009-02-27, is 11, should be valid=0
    ok 7 - Today=2020-02-28, dob=2016-08-27, is 3, should be valid=0
    ok 8 - Today=2020-02-28, dob=2009-03-01, is 11, should be valid=1
    ok 9 - Today=2020-02-28, dob=2007-08-27, is 12, should be valid=0
    ok 10 - Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1

Some ages are incorrect :

1) dob=2009-03-01, is 11
=> it is age 10
so valid=1 in category 5 to 10

2) dob=2015-03-01, is 5
=> it is age 4
so valid=0 in category 5 to 10

3) dob=2015-02-28, is 7
=> this date of birth is already tested
I suppose here dob is wrong, age wanted is 7 in the middle of age restrictions.
so dob=2013-02-28

This patch fixes ages.
Also adds the category code 'AGE_5_10' in messages to display age limits

Test plan :
Run prove -v t/db_dependent/Koha/Patrons.t without and with patch
Comment 2 David Nind 2021-08-17 21:19:13 UTC
Created attachment 123915 [details] [review]
Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t

In test suite db_dependent/Koha/Patrons.t actually shows :

    1..10
    ok 1 - Patron with no dateofbirth is always valid for any category
    ok 2 - Today=2020-02-28, dob=2015-03-01, is 5, should be valid=0
    ok 3 - Today=2020-02-28, dob=2015-02-27, is 5, should be valid=1
    ok 4 - Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0
    ok 5 - Today=2020-02-28, dob=2015-02-28, is 7, should be valid=1
    ok 6 - Today=2020-02-28, dob=2009-02-27, is 11, should be valid=0
    ok 7 - Today=2020-02-28, dob=2016-08-27, is 3, should be valid=0
    ok 8 - Today=2020-02-28, dob=2009-03-01, is 11, should be valid=1
    ok 9 - Today=2020-02-28, dob=2007-08-27, is 12, should be valid=0
    ok 10 - Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1

Some ages are incorrect :

1) dob=2009-03-01, is 11
=> it is age 10
so valid=1 in category 5 to 10

2) dob=2015-03-01, is 5
=> it is age 4
so valid=0 in category 5 to 10

3) dob=2015-02-28, is 7
=> this date of birth is already tested
I suppose here dob is wrong, age wanted is 7 in the middle of age restrictions.
so dob=2013-02-28

This patch fixes ages.
Also adds the category code 'AGE_5_10' in messages to display age limits

Test plan :
Run prove -v t/db_dependent/Koha/Patrons.t without and with patch

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2021-08-17 21:21:04 UTC
Testing notes (koha-testing-docker):
- Look for test 19 - is_valid_age
Comment 4 Katrin Fischer 2021-08-17 21:57:14 UTC
Created attachment 123916 [details] [review]
Bug 28873: Fix age displayed in db_dependent/Koha/Patrons.t

In test suite db_dependent/Koha/Patrons.t actually shows :

    1..10
    ok 1 - Patron with no dateofbirth is always valid for any category
    ok 2 - Today=2020-02-28, dob=2015-03-01, is 5, should be valid=0
    ok 3 - Today=2020-02-28, dob=2015-02-27, is 5, should be valid=1
    ok 4 - Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0
    ok 5 - Today=2020-02-28, dob=2015-02-28, is 7, should be valid=1
    ok 6 - Today=2020-02-28, dob=2009-02-27, is 11, should be valid=0
    ok 7 - Today=2020-02-28, dob=2016-08-27, is 3, should be valid=0
    ok 8 - Today=2020-02-28, dob=2009-03-01, is 11, should be valid=1
    ok 9 - Today=2020-02-28, dob=2007-08-27, is 12, should be valid=0
    ok 10 - Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1

Some ages are incorrect :

1) dob=2009-03-01, is 11
=> it is age 10
so valid=1 in category 5 to 10

2) dob=2015-03-01, is 5
=> it is age 4
so valid=0 in category 5 to 10

3) dob=2015-02-28, is 7
=> this date of birth is already tested
I suppose here dob is wrong, age wanted is 7 in the middle of age restrictions.
so dob=2013-02-28

This patch fixes ages.
Also adds the category code 'AGE_5_10' in messages to display age limits

Test plan :
Run prove -v t/db_dependent/Koha/Patrons.t without and with patch

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Jonathan Druart 2021-08-18 13:37:05 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall 2021-08-20 17:57:41 UTC
Pushed to 21.05.x for 21.05.03
Comment 7 Fridolin Somers 2021-08-27 19:00:11 UTC
Pushed to 20.11.x for 20.11.10
Comment 8 Victor Grousset/tuxayo 2021-08-31 04:30:13 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.