Everywhere where Test::DBIx::Class is used, a following blob of code follows: use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''], connect_opts => { name_sep => '.', quote_char => '`', }, fixture_class => '::Populate', }, 'SocialData', 'Biblioitem' ; Instead of duplicating this same code everywhere, use a default configuration for a Test::DBIx::Class in t/etc/schema.pl
Created attachment 60885 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication Is 'instantiations' even a word? Use a Test::DBIx::Class defaults instead. Save your keyboard and prevent horrible bugs from emerging from rampant code duplication. This change doesn't seem to have any impact on the speed of executing those tests.
Created attachment 60886 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 t/00-load.t already checks if all of the perl modules can be compiled. The tests deleted in this commit do a duplicate test with t/00-load.t Hence they have become unnecessary.
t/db_dependent/Circulation/CalcDateDue.t fails with date calculus. SQLite is peculiar with date calculus.
Created attachment 60920 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 Couldn't make the tests pass using Test::DBIx::Class, so reverted to the "usual way" since these tests are in db_dependent anyway.
Created attachment 60923 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication Is 'instantiations' even a word? Use a Test::DBIx::Class defaults instead. Save your keyboard and prevent horrible bugs from emerging from rampant code duplication. This change doesn't seem to have any impact on the speed of executing those tests.
See the blocked list of Bugs for more individual test fixes.
% git log --oneline 619aa5f Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 5fb9461 Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 5875738 Bug 18286 - Test::DBIx::Class connection/schema is shadowed by a cached connection/schema 8814c10 Bug 18285 - Koha::Database schema cache accessors Last patch from this bug does not apply: t/Members/cardnumber.t .. # Can't initialize a schema with the given configuration # Returned Error: `' is not a module name # configuration: { # 'fixture_sets' => {} # } % pmvers Test::DBIx::Class 0.52
% git log --oneline 619aa5f Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 5fb9461 Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 5875738 Bug 18286 - Test::DBIx::Class connection/schema is shadowed by a cached connection/schema 8814c10 Bug 18285 - Koha::Database schema cache accessors Last patch from this bug does not apply! % prove t/Members/cardnumber. t/Members/cardnumber.t .. # Can't initialize a schema with the given configuration # Returned Error: `' is not a module name # configuration: { # 'fixture_sets' => {} # } ... % pmvers Test::DBIx::Class 0.52
does not apply on top of 18285 and 18286
Applying: Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication fatal: sha1 information is lacking or useless (t/Calendar.t).
Created attachment 62960 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 t/00-load.t already checks if all of the perl modules can be compiled. The tests deleted in this commit do a duplicate test with t/00-load.t Hence they have become unnecessary.
Created attachment 62961 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 Couldn't make the tests pass using Test::DBIx::Class, so reverted to the "usual way" since these tests are in db_dependent anyway.
Created attachment 62962 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication Is 'instantiations' even a word? Use a Test::DBIx::Class defaults instead. Save your keyboard and prevent horrible bugs from emerging from rampant code duplication. This change doesn't seem to have any impact on the speed of executing those tests.
Created attachment 62968 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 t/00-load.t already checks if all of the perl modules can be compiled. The tests deleted in this commit do a duplicate test with t/00-load.t Hence they have become unnecessary. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 62969 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 Couldn't make the tests pass using Test::DBIx::Class, so reverted to the "usual way" since these tests are in db_dependent anyway. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 62970 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication Is 'instantiations' even a word? Use a Test::DBIx::Class defaults instead. Save your keyboard and prevent horrible bugs from emerging from rampant code duplication. This change doesn't seem to have any impact on the speed of executing those tests. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Moved the t/etc/schema to an earlier report.
The comparaison $libCount = Koha::Libraries->search->count does not work when there is no libraries defined (0 vs undef) prove t/db_dependent/01-test_dbic.t t/db_dependent/01-test_dbic.t .. # Failed test ' When the libraries are counted' # at t/db_dependent/01-test_dbic.t line 41. # Looks like you failed 1 test of 19. t/db_dependent/01-test_dbic.t .. 1/? # Failed test 'Scenario: Show how caching prevents Test::DBIx::Class from working properly and how to circumvent it' # at t/db_dependent/01-test_dbic.t line 95. # Looks like you failed 1 test of 1. t/db_dependent/01-test_dbic.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests Test Summary Report ------------------- t/db_dependent/01-test_dbic.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 Files=1, Tests=1, 3 wallclock secs ( 0.02 usr 0.02 sys + 2.09 cusr 0.88 csys = 3.01 CPU) Result: FAIL You should also use is instead of ok and follow the coding guidelines of the project (camel_case for instance), please... $verbose should be removed
(In reply to Jonathan Druart from comment #18) > The comparaison > $libCount = Koha::Libraries->search->count > does not work when there is no libraries defined (0 vs undef) Hmm. I think it is an assignment, not an comparison. Both 0 and undef will be interpreted as false by ok. (Note that I am not the author.)
Created attachment 63688 [details] [review] Bug 18226: [QA Follow-up] Remove further assumptions on branch count See also follow-up on bug 18286. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 63689 [details] [review] Bug 18226: [QA Follow-up] Remove verbose Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(In reply to Jonathan Druart from comment #18) > prove t/db_dependent/01-test_dbic.t Please try again with the follow-ups. > You should also use is instead of ok and follow the coding guidelines of the > project (camel_case for instance), please... Not sure what you exactly want here. The lines where ok now is called, are fine with me. I'd rather see ok than using 'is' for comparing with false. Please specify which names should be adjusted. > $verbose should be removed Fixed
Wanted to apply for testing Bug 18287 on top of this bug, but fails with: Bug 18226: [QA Follow-up] Remove further assumptions on branch count fatal: sha1 information is lacking or useless (t/db_dependent/01-test_dbic.t).
(In reply to Marc Véron from comment #23) > Wanted to apply for testing Bug 18287 on top of this bug, but fails with: > > Bug 18226: [QA Follow-up] Remove further assumptions on branch count > fatal: sha1 information is lacking or useless > (t/db_dependent/01-test_dbic.t). Applies fine with me, no conflicts or so. Did you apply the dependencies? 18285 and 18286
Created attachment 63999 [details] [review] Bug 18226: Perltidy + license
Created attachment 64008 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 1 t/00-load.t already checks if all of the perl modules can be compiled. The tests deleted in this commit do a duplicate test with t/00-load.t Hence they have become unnecessary. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 64009 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 Couldn't make the tests pass using Test::DBIx::Class, so reverted to the "usual way" since these tests are in db_dependent anyway. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 64010 [details] [review] Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication Is 'instantiations' even a word? Use a Test::DBIx::Class defaults instead. Save your keyboard and prevent horrible bugs from emerging from rampant code duplication. This change doesn't seem to have any impact on the speed of executing those tests. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 64011 [details] [review] Bug 18226: [QA Follow-up] Remove further assumptions on branch count See also follow-up on bug 18286. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 64012 [details] [review] Bug 18226: [QA Follow-up] Remove verbose Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 64013 [details] [review] Bug 18226: Perltidy + license Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed to master for 17.11, thanks to everybody involved!
Enhancement not pushed to 17.05.x