Bug 13276

Summary: t/XSLT.t shouldn't depend on the DB
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Test SuiteAssignee: Chris Cormack <chris>
Status: CLOSED FIXED QA Contact: Galen Charlton <gmcharlt>
Severity: normal    
Priority: P5 - low CC: jonathan.druart, magnus
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 13275    
Attachments: Bug 13276: t/XSLT.t shouldn't depend on the DB
Bug 13276: t/XSLT.t shouldn't depend on the DB
[PASSED QA] Bug 13276: t/XSLT.t shouldn't depend on the DB
Bug 13276: use t::lib::Mocks::mock_dbh

Description Tomás Cohen Arazi 2014-11-18 03:50:01 UTC
t/XSLT.t should mock the DB
Comment 1 Tomás Cohen Arazi 2014-11-18 03:53:18 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2014-11-18 07:13:26 UTC
*Before* applying the patch:

$ sudo koha-shell -c "prove  t/XSLT.t" kohadev
t/XSLT.t .. ok   
All tests successful.
Files=1, Tests=8,  2 wallclock secs ( 0.02 usr  0.01 sys +  0.48 cusr  0.45 csys =  0.96 CPU)
Result: PASS

As far as I can tell, the patch adds mocking of C4::Context but never uses that for anything? Perhaps I am missing something but I'm setting this to Failed QA.
Comment 3 Chris Cormack 2014-11-18 07:20:26 UTC
Before patch I get

#   Failed test 'use C4::XSLT;'
#   at t/XSLT.t line 14.
#     Tried to use 'C4::XSLT'.
#     Error:  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at C4/Context.pm line 785.

After the patch it works
Comment 4 Chris Cormack 2014-11-18 07:21:23 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2014-11-18 07:29:13 UTC
Created attachment 33640 [details] [review]
[PASSED QA] Bug 13276: t/XSLT.t shouldn't depend on the DB

To reproduce:
- Stop your MySQL server:
  $ sudo service mysql stop
- Run
  $ prove t/XSLT.t
=> FAIL: some tests fail because of mysql stopped

To test (MySQL still stopped)
- Apply the patch
- Run
  $ prove t/XSLT.t
=> SUCCESS: tests pass because the ycan be loaded regardless of
            the absence of the DB server
- Sign off :-D

Regards

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tests pass without db connection for me now.
Comment 6 Jonathan Druart 2014-11-18 09:58:21 UTC
Created attachment 33646 [details] [review]
Bug 13276: use t::lib::Mocks::mock_dbh

To use this patch, patch from bug 13274 should be applied too.
Comment 7 Jonathan Druart 2014-11-18 09:59:35 UTC
The last patch reintroduces the use_ok into the BEGIN block and use the mock subroutine introduced by the patch on bug 13274 comment 4.
Feel free not to use/push it.
Comment 8 Tomás Cohen Arazi 2014-11-19 14:42:03 UTC
Patches pushed to master.

Thanks Jonathan!