Bugzilla – Attachment 64010 Details for
Bug 18226
Remove "use Test::DBIx::Class" instantiations' dangerous code duplication
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication
Bug-18226---Remove-use-TestDBIxClass-instantiation.patch (text/plain), 8.06 KB, created by
Jonathan Druart
on 2017-06-05 20:54:56 UTC
(
hide
)
Description:
Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-06-05 20:54:56 UTC
Size:
8.06 KB
patch
obsolete
>From 1847c1e1b5cca6fa4aef60e68273d84f2ea86ee5 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 7 Mar 2017 18:56:29 +0200 >Subject: [PATCH] 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> >--- > t/Auth_with_shibboleth.t | 2 +- > t/Biblio.t | 8 ++------ > t/Calendar.t | 7 +------ > t/Images.t | 7 +------ > t/Koha.t | 7 +------ > t/Letters.t | 7 +------ > t/Matcher.t | 7 +------ > t/Members_AttributeTypes.t | 7 +------ > t/NorwegianPatronDB.t | 7 +------ > t/Prices.t | 7 +------ > t/SocialData.t | 7 +------ > t/XSLT.t | 15 ++------------- > t/db_dependent/Sitemapper.t | 7 +------ > 13 files changed, 15 insertions(+), 80 deletions(-) > >diff --git a/t/Auth_with_shibboleth.t b/t/Auth_with_shibboleth.t >index 3b357093ba..ab03248d0f 100644 >--- a/t/Auth_with_shibboleth.t >+++ b/t/Auth_with_shibboleth.t >@@ -34,7 +34,7 @@ BEGIN { > } > } > >-use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''] }; >+use Test::DBIx::Class; > > # Mock Variables > my $matchpoint = 'userid'; >diff --git a/t/Biblio.t b/t/Biblio.t >index 1cec33be51..1bf7895d00 100755 >--- a/t/Biblio.t >+++ b/t/Biblio.t >@@ -33,12 +33,8 @@ BEGIN { > > use_ok('C4::Biblio'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Biblio' ; >+#use Test::DBIx::Class {}, 'Biblio'; >+use Test::DBIx::Class; #No difference between these two invocations in time taken to execute tests. > > sub fixtures { > my ( $data ) = @_; >diff --git a/t/Calendar.t b/t/Calendar.t >index 3082271b06..076eb8d71a 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -37,12 +37,7 @@ BEGIN { > > use_ok('Koha::Calendar'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Biblio' ; >+use Test::DBIx::Class; > > sub fixtures { > my ( $data ) = @_; >diff --git a/t/Images.t b/t/Images.t >index 0ee5ce683e..02bcd82a45 100644 >--- a/t/Images.t >+++ b/t/Images.t >@@ -32,12 +32,7 @@ BEGIN { > > use_ok('C4::Images'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Biblioimage' ; >+use Test::DBIx::Class; > > # Make the code in the module use our mocked Koha::Schema/Koha::Database > my $db = Test::MockModule->new('Koha::Database'); >diff --git a/t/Koha.t b/t/Koha.t >index e617146f93..2e11ab7b48 100755 >--- a/t/Koha.t >+++ b/t/Koha.t >@@ -33,12 +33,7 @@ BEGIN { > > use_ok('C4::Koha'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Branch' ; >+use Test::DBIx::Class; > > sub fixtures { > my ( $libraries ) = @_; >diff --git a/t/Letters.t b/t/Letters.t >index 76c5a875a0..fb1158bf52 100755 >--- a/t/Letters.t >+++ b/t/Letters.t >@@ -30,12 +30,7 @@ BEGIN { > } > } > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Letter' ; >+use Test::DBIx::Class; > use t::lib::Mocks; > > fixtures_ok [ >diff --git a/t/Matcher.t b/t/Matcher.t >index 3d7f6e9c9b..30d1b90fd0 100755 >--- a/t/Matcher.t >+++ b/t/Matcher.t >@@ -35,12 +35,7 @@ BEGIN { > > use_ok('C4::Matcher'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'MarcMatcher' ; >+use Test::DBIx::Class; > > fixtures_ok [ > MarcMatcher => [ >diff --git a/t/Members_AttributeTypes.t b/t/Members_AttributeTypes.t >index 4721fad276..42b04d57d4 100755 >--- a/t/Members_AttributeTypes.t >+++ b/t/Members_AttributeTypes.t >@@ -32,12 +32,7 @@ BEGIN { > > use_ok('C4::Members::AttributeTypes'); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'BorrowerAttributeType', 'Category' ; >+use Test::DBIx::Class; > > fixtures_ok [ > Category => [ >diff --git a/t/NorwegianPatronDB.t b/t/NorwegianPatronDB.t >index 1f0808caa2..ec630203d6 100644 >--- a/t/NorwegianPatronDB.t >+++ b/t/NorwegianPatronDB.t >@@ -60,12 +60,7 @@ BEGIN { > } > } > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Borrower', 'BorrowerSync'; >+use Test::DBIx::Class {}, 'Borrower', 'BorrowerSync'; #Also loads those modules. > > # Make the code in the module use our mocked Koha::Schema/Koha::Database > my $db = Test::MockModule->new('Koha::Database'); >diff --git a/t/Prices.t b/t/Prices.t >index f89c7f6dae..c65f2033a8 100644 >--- a/t/Prices.t >+++ b/t/Prices.t >@@ -20,12 +20,7 @@ use_ok('Koha::Number::Price'); > > t::lib::Mocks::mock_preference( 'gist', '0.02|0.05|0.196' ); > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Currency' ; >+use Test::DBIx::Class; > > my $db = Test::MockModule->new('Koha::Database'); > $db->mock( _new_schema => sub { return Schema(); } ); >diff --git a/t/SocialData.t b/t/SocialData.t >index 8b6a93b268..eec1e5cf07 100644 >--- a/t/SocialData.t >+++ b/t/SocialData.t >@@ -34,12 +34,7 @@ BEGIN { > use_ok('C4::SocialData'); > } > >-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' ; >+use Test::DBIx::Class; > > fixtures_ok [ > Biblioitem => [ >diff --git a/t/XSLT.t b/t/XSLT.t >index 71363755f5..aefa4df531 100755 >--- a/t/XSLT.t >+++ b/t/XSLT.t >@@ -27,7 +27,7 @@ use Module::Load::Conditional qw/check_install/; > > BEGIN { > if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 10; >+ plan tests => 9; > } else { > plan skip_all => "Need Test::DBIx::Class" > } >@@ -35,18 +35,7 @@ BEGIN { > use_ok('C4::XSLT'); > }; > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Branch' ; >- >-fixtures_ok [ >- Branch => [ >- ], >-]; >- >+use Test::DBIx::Class; > > my $dir = File::Temp->newdir(); > my @themes = ('prog', 'test'); >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index 848fc3b3fa..4276470728 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/t/db_dependent/Sitemapper.t >@@ -40,12 +40,7 @@ sub slurp { > return $cont; > } > >-use Test::DBIx::Class { >- schema_class => 'Koha::Schema', >- connect_info => ['dbi:SQLite:dbname=:memory:','',''], >- connect_opts => { name_sep => '.', quote_char => '`', }, >- fixture_class => '::Populate', >-}, 'Biblio' ; >+use Test::DBIx::Class; > > sub fixtures { > my ( $data ) = @_; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18226
:
60885
|
60886
|
60920
|
60923
|
62960
|
62961
|
62962
|
62968
|
62969
|
62970
|
63688
|
63689
|
63999
|
64008
|
64009
| 64010 |
64011
|
64012
|
64013