Bug 21817

Summary: Mock userenv should be a t::lib::Mocks method
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: enhancement    
Priority: P5 - low CC: dcook, katrin.fischer, martin.renvoize, nick, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Test suite enhancement backported to 18.11.x series to aid future backports. There should be no noticeable effects for the end user.
Version(s) released in:
Bug Depends on:    
Bug Blocks: 21816, 22850    
Attachments: Bug 21817: Centralize the mock of userenv from tests
Bug 21817: Centralize the mock of userenv from tests
Bug 21817: Fix 2 failing tests
Bug 21817: Centralize the mock of userenv from tests
Bug 21817: Fix 2 failing tests
Bug 21817: Centralize the mock of userenv from tests
Bug 21817: Fix 2 failing tests
Bug 21817: Centralize the mock of userenv from tests
Bug 21817: Fix 2 failing tests

Description Jonathan Druart 2018-11-12 21:24:17 UTC

    
Comment 1 Jonathan Druart 2018-11-12 21:26:39 UTC
Created attachment 82250 [details] [review]
Bug 21817: Centralize the mock of userenv from tests

This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.

Test plan:
prove all the test files modified by this patch
Comment 2 Martin Renvoize 2018-12-10 18:35:32 UTC
Created attachment 83023 [details] [review]
Bug 21817: Centralize the mock of userenv from tests

This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.

Test plan:
prove all the test files modified by this patch

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize 2018-12-10 18:36:10 UTC
Good call.. all tests still pass for me after applying.  Signed off.
Comment 4 Tomás Cohen Arazi 2018-12-11 14:21:30 UTC
All looks good! But some new warnings are generated and some tests fail.

To reproduce:

 $ kshell
k$ git diff HEAD~ --name-only | grep -e '\.t$' | xargs prove

=> FAIL: Tests fail:

...
t/db_dependent/Acquisition/NewOrder.t ........................ 1/8
#   Failed test 'Koha::Acquisition::Order->store set created_by to logged in user if not given'
#   at t/db_dependent/Acquisition/NewOrder.t line 92.
#          got: '51'
#     expected: '42'
# Looks like you failed 1 test of 8.
t/db_dependent/Acquisition/NewOrder.t ........................ Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/8 subtests
t/db_dependent/ArticleRequests.t ............................. ok
t/db_dependent/Bookseller.t .................................. 28/86
#   Failed test 'ordinary user can see only their library's subscriptions with IndependentBranches on'
#   at t/db_dependent/Bookseller.t line 667.
#          got: '0'
#     expected: '1'
# Looks like you failed 1 test of 86.
t/db_dependent/Bookseller.t .................................. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/86 subtests
...
Comment 5 Jonathan Druart 2018-12-11 15:29:48 UTC
Created attachment 83052 [details] [review]
Bug 21817: Fix 2 failing tests
Comment 6 Tomás Cohen Arazi 2018-12-12 14:37:33 UTC
Created attachment 83123 [details] [review]
Bug 21817: Centralize the mock of userenv from tests

This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.

Test plan:
prove all the test files modified by this patch

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Tomás Cohen Arazi 2018-12-12 14:37:42 UTC
Created attachment 83124 [details] [review]
Bug 21817: Fix 2 failing tests
Comment 8 Tomás Cohen Arazi 2018-12-12 14:44:36 UTC
Created attachment 83125 [details] [review]
Bug 21817: Centralize the mock of userenv from tests

This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.

Test plan:
prove all the test files modified by this patch

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi 2018-12-12 14:44:43 UTC
Created attachment 83126 [details] [review]
Bug 21817: Fix 2 failing tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Nick Clemens 2018-12-26 16:44:47 UTC
Please rebase
Comment 11 Tomás Cohen Arazi 2018-12-26 18:22:29 UTC
Created attachment 83515 [details] [review]
Bug 21817: Centralize the mock of userenv from tests

This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.

Test plan:
prove all the test files modified by this patch

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Tomás Cohen Arazi 2018-12-26 18:22:35 UTC
Created attachment 83516 [details] [review]
Bug 21817: Fix 2 failing tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Nick Clemens 2019-01-02 21:10:05 UTC
Awesome work all!

Pushed to master for 19.05
Comment 14 Martin Renvoize 2019-01-07 14:52:01 UTC
At this early stage in the cycle, I have decided to backport this one as I'm envisaging it may be required by future ports and it doesn't cause any noticable changes for the end user.

Pushed to 18.11.x for 18.11.02

RMaint note, I personally wouldn't feel the need to port this any further back than the 18.11.x series.