Bug 7143: Updating the About page with translation teams for Basque and Turkish
[koha_fer] / t / Letters.t
old mode 100644 (file)
new mode 100755 (executable)
index 1a669ea..2d5f557
@@ -1,5 +1,34 @@
-BEGIN { $| = 1; print "1..1\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use C4::Letters;
-$loaded = 1;
-print "ok 1\n";
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!
+# Add more tests here!!!
+
+use strict;
+use warnings;
+use Test::MockModule;
+use Test::More tests => 2;
+
+my $module = new Test::MockModule('C4::Context');
+$module->mock(
+    '_new_dbh',
+    sub {
+        my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
+          || die "Cannot create handle: $DBI::errstr\n";
+        return $dbh;
+    }
+);
+my $mock_letters = [
+    [ 'module', 'code', 'branchcode', 'name', 'is_html', 'title', 'content' ],
+    [ 'blah',   'ISBN', 'NBSI',       'book', 1,         'green', 'blahblah' ],
+    [ 'bleh',   'ISSN', 'NSSI',       'page', 0,         'blue',  'blehbleh' ]
+];
+
+use_ok('C4::Letters');
+
+my $dbh = C4::Context->dbh();
+
+$dbh->{mock_add_resultset} = $mock_letters;
+
+my $letters = C4::Letters::GetLetters();
+
+is( $letters->{ISBN}, 'book', 'HASH ref of ISBN is book' );