@@ -, +, @@ Test::DBIx::Class absent - Install Test::DBIx::Class $ sudo cpanm Test::DBIx::Class - Run the tests: $ prove t/ - Uninstall Test::DBIx::Class $ sudo cpan -U Test::DBIx::Class - Run the tests: $ prove t/ - Sign off :-D --- t/Biblio.t | 12 ++++++++++-- t/Calendar.t | 40 ++++++++++++++++++++++++++++++++-------- t/Images.t | 30 ++++++++++++++++++++++++++++-- t/ItemType.t | 30 +++++++++++++++++++++++++++++- t/Koha.t | 12 +++++++++++- t/Letters.t | 13 +++++++++++-- t/Matcher.t | 33 ++++++++++++++++++++++++++++----- t/Members_AttributeTypes.t | 28 +++++++++++++++++++++++++--- t/SocialData.t | 30 ++++++++++++++++++++++++++++-- 9 files changed, 202 insertions(+), 26 deletions(-) --- a/t/Biblio.t +++ a/t/Biblio.t @@ -17,14 +17,22 @@ use Modern::Perl; -use Test::More tests => 46; +use Test::More; use Test::MockModule; use Test::Warn; +use Module::Load::Conditional qw/check_install/; + BEGIN { - use_ok('C4::Biblio'); + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 46; + } else { + plan skip_all => "Need Test::DBIx::Class" + } } +use_ok('C4::Biblio'); + use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''], --- a/t/Calendar.t +++ a/t/Calendar.t @@ -1,20 +1,42 @@ -#!/usr/bin/env perl +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; + +use Test::More; +use Test::MockModule; + use DateTime; use DateTime::Duration; -use Test::More tests => 35; -use Test::MockModule; use Koha::Cache; use Koha::DateUtils; -BEGIN { - use_ok('Koha::Calendar'); +use Module::Load::Conditional qw/check_install/; - # This was the only test C4 had - # Remove when no longer used - #use_ok('C4::Calendar'); # not used anymore? +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 35; + } else { + plan skip_all => "Need Test::DBIx::Class" + } } + +use_ok('Koha::Calendar'); + use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''], @@ -298,3 +320,5 @@ my $day_after_christmas = DateTime->new( '==', 40, 'Test parameter order not relevant (Days)' ); } + +1; --- a/t/Images.t +++ a/t/Images.t @@ -1,11 +1,35 @@ #!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -#Testing C4 Images +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 8; + +use Test::More; use Test::MockModule; +use Module::Load::Conditional qw/check_install/; + +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 8; + } else { + plan skip_all => "Need Test::DBIx::Class" + } +} + use_ok('C4::Images'); use Test::DBIx::Class { @@ -49,3 +73,5 @@ is( $imagenumbers[0], 1, 'imagenumber is 1' ); is( $imagenumbers[1], 3, 'imagenumber is 3' ); is( $imagenumbers[4], undef, 'imagenumber undef' ); + +1; --- a/t/ItemType.t +++ a/t/ItemType.t @@ -1,9 +1,35 @@ #!/usr/bin/perl +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + use Modern::Perl; -use Test::More tests => 25; + +use Test::More; use t::lib::Mocks; +use Module::Load::Conditional qw/check_install/; + +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 25; + } else { + plan skip_all => "Need Test::DBIx::Class" + } +} + use_ok('C4::ItemType'); use Test::DBIx::Class { @@ -90,3 +116,5 @@ is( $itemtype->checkinmsg, 'foo', 'checkinmsg is foo' ); $itemtype = C4::ItemType->get; is( $itemtype, undef, 'C4::ItemType->get should return unless if no parameter is given' ); + +1; --- a/t/Koha.t +++ a/t/Koha.t @@ -18,9 +18,19 @@ use Modern::Perl; use C4::Context; -use Test::More tests => 30; +use Test::More; use Test::MockModule; +use Module::Load::Conditional qw/check_install/; + +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 30; + } else { + plan skip_all => "Need Test::DBIx::Class" + } +} + use_ok('C4::Koha'); use Test::DBIx::Class { --- a/t/Letters.t +++ a/t/Letters.t @@ -17,9 +17,18 @@ use Modern::Perl; -use DBI; use Test::MockModule; -use Test::More tests => 6; +use Test::More; + +use Module::Load::Conditional qw/check_install/; + +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 6; + } else { + plan skip_all => "Need Test::DBIx::Class" + } +} use Test::DBIx::Class { schema_class => 'Koha::Schema', --- a/t/Matcher.t +++ a/t/Matcher.t @@ -1,16 +1,37 @@ #!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -#testing C4 matcher +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; -use strict; -use warnings; -use Test::More tests => 11; +use Test::More; use Test::MockModule; +use Module::Load::Conditional qw/check_install/; + BEGIN { - use_ok('C4::Matcher'); + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 11; + } else { + plan skip_all => "Need Test::DBIx::Class" + } } +use_ok('C4::Matcher'); + use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''], @@ -60,3 +81,5 @@ is( $testmatcher->code(), 'match on ISBN', 'testing code accessor' ); $testmatcher->description('match on ISSN'); is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' ); + +1; --- a/t/Members_AttributeTypes.t +++ a/t/Members_AttributeTypes.t @@ -1,15 +1,37 @@ #!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# Tests 'fetch', 'fake db data', and 'checks for existant attributes' +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; + use Test::MockModule; -use Test::More tests => 10; +use Test::More; + +use Module::Load::Conditional qw/check_install/; BEGIN { - use_ok('C4::Members::AttributeTypes'); + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 10; + } else { + plan skip_all => "Need Test::DBIx::Class" + } } +use_ok('C4::Members::AttributeTypes'); + use Test::DBIx::Class { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''], --- a/t/SocialData.t +++ a/t/SocialData.t @@ -1,11 +1,35 @@ #!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#Testing C4 SocialData +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 6; + +use Test::More; use Test::MockModule; +use Module::Load::Conditional qw/check_install/; + +BEGIN { + if ( check_install( module => 'Test::DBIx::Class' ) ) { + plan tests => 6; + } else { + plan skip_all => "Need Test::DBIx::Class" + } +} + BEGIN { use_ok('C4::SocialData'); } @@ -51,3 +75,5 @@ is( $report->{'without'}->[0]->{'original'}, is( $report->{'without'}->[0]->{'isbn'}, '9780596526740', 'testing get_report' ); + +1; --