Bug 18399: Add reasons in edit suggestion page
[koha.git] / t / Koha.t
index e887632..b8d4346 100755 (executable)
--- a/t/Koha.t
+++ b/t/Koha.t
@@ -25,7 +25,7 @@ use Module::Load::Conditional qw/check_install/;
 
 BEGIN {
     if ( check_install( module => 'Test::DBIx::Class' ) ) {
-        plan tests => 34;
+        plan tests => 38;
     } else {
         plan skip_all => "Need Test::DBIx::Class"
     }
@@ -33,20 +33,11 @@ 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',
-}, 'AuthorisedValue', 'Branch' ;
+use Test::DBIx::Class;
 
 sub fixtures {
-    my ( $av, $libraries ) = @_;
+    my ( $libraries ) = @_;
     fixtures_ok [
-        AuthorisedValue => [
-            [ 'category', 'authorised_value' ],
-            @$av,
-        ],
         Branch => [
             ['branchcode', 'branchname'],
             @$libraries,
@@ -56,19 +47,12 @@ sub fixtures {
 
 my $db = Test::MockModule->new('Koha::Database');
 $db->mock( _new_schema => sub { return Schema(); } );
+Koha::Database::flush_schema_cache();
 
-my $authorised_values = [
-    ['LOC', 'LOC'],
-    ['RELTERMS', 'RELTERMS'],
-];
 my $libraries = [
     ['XXX_test', 'my branchname XXX'],
 ];
-fixtures($authorised_values, $libraries);
-
-is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
-is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
-is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
+fixtures($libraries);
 
 my $isbn13 = "9780330356473";
 my $isbn13D = "978-0-330-35647-3";
@@ -139,7 +123,7 @@ subtest 'getFacets() tests' => sub {
         ['YYY_test', 'my branchname YYY'],
         ['ZZZ_test', 'my branchname XXX'],
     ];
-    fixtures($authorised_values, $libraries);
+    fixtures($libraries);
     is ( Koha::Libraries->search->count, 3, 'There should be only more than 1 library (singleBranchMode off)' );
 
     $facets = C4::Koha::getFacets();
@@ -150,4 +134,20 @@ subtest 'getFacets() tests' => sub {
     );
 };
 
-1;
+is(C4::Koha::NormalizeISSN({ issn => '0024-9319', strip_hyphen => 1 }), '00249319', 'Test NormalizeISSN with all features enabled' );
+is(C4::Koha::NormalizeISSN({ issn => '0024-9319', strip_hyphen => 0 }), '0024-9319', 'Test NormalizeISSN with all features enabled' );
+
+my @issns = qw/ 0024-9319 00249319 /;
+is( join('|', @issns), join('|', GetVariationsOfISSN('0024-9319')), 'GetVariationsOfISSN returns all variations' );
+is( join('|', @issns), join('|', GetVariationsOfISSNs('0024-9319')), 'GetVariationsOfISSNs returns all variations' );
+
+my $issn;
+eval {
+    $issn = C4::Koha::NormalizeISSN({ issn => '1234-5678', strip_hyphen => 1 });
+};
+ok($@ eq '', 'NormalizeISSN does not throw exception when parsing invalid ISSN');
+
+@issns = GetVariationsOfISSNs('abc');
+is($issns[0], 'abc', 'Original ISSN passed through even if invalid');
+is(scalar(@issns), 1, 'zero additional variations returned of invalid ISSN');
+