[Koha-patches] [PATCH] Tests for New Modules
Daniel Sweeney
daniel.sweeney at liblime.com
Tue Feb 3 23:02:10 CET 2009
From: John Beppu <john.beppu at liblime.com>
- KohaTest::Category
- KohaTest::ItemCirculationAlertPreference
- KohaTest::ItemType
- KohaTest::Message
Signed-off-by: Daniel Sweeney <daniel.sweeney at liblime.com>
---
t/lib/KohaTest/Category.pm | 23 ++++++++++
t/lib/KohaTest/ItemCirculationAlertPreference.pm | 27 +++++++++++
t/lib/KohaTest/ItemType.pm | 23 ++++++++++
t/lib/KohaTest/Message.pm | 52 ++++++++++++++++++++++
4 files changed, 125 insertions(+), 0 deletions(-)
create mode 100644 t/lib/KohaTest/Category.pm
create mode 100644 t/lib/KohaTest/ItemCirculationAlertPreference.pm
create mode 100644 t/lib/KohaTest/ItemType.pm
create mode 100644 t/lib/KohaTest/Message.pm
diff --git a/t/lib/KohaTest/Category.pm b/t/lib/KohaTest/Category.pm
new file mode 100644
index 0000000..3febfda
--- /dev/null
+++ b/t/lib/KohaTest/Category.pm
@@ -0,0 +1,23 @@
+package KohaTest::Category;
+use base qw( KohaTest );
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use C4::Category;
+sub testing_class { 'C4::Category' };
+
+
+sub methods : Test( 1 ) {
+ my $self = shift;
+ my @methods = qw(
+ new
+ all
+ );
+
+ can_ok( $self->testing_class, @methods );
+}
+
+1;
diff --git a/t/lib/KohaTest/ItemCirculationAlertPreference.pm b/t/lib/KohaTest/ItemCirculationAlertPreference.pm
new file mode 100644
index 0000000..3094b33
--- /dev/null
+++ b/t/lib/KohaTest/ItemCirculationAlertPreference.pm
@@ -0,0 +1,27 @@
+package KohaTest::ItemCirculationAlertPreference;
+use base qw( KohaTest );
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use C4::ItemCirculationAlertPreference;
+sub testing_class { 'C4::ItemCirculationAlertPreference' };
+
+
+sub methods : Test( 1 ) {
+ my $self = shift;
+ my @methods = qw(
+ new
+ create
+ delete
+ is_enabled_for
+ find
+ grid
+ );
+
+ can_ok( $self->testing_class, @methods );
+}
+
+1;
diff --git a/t/lib/KohaTest/ItemType.pm b/t/lib/KohaTest/ItemType.pm
new file mode 100644
index 0000000..2474ce3
--- /dev/null
+++ b/t/lib/KohaTest/ItemType.pm
@@ -0,0 +1,23 @@
+package KohaTest::ItemType;
+use base qw( KohaTest );
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use C4::ItemType;
+sub testing_class { 'C4::ItemType' };
+
+
+sub methods : Test( 1 ) {
+ my $self = shift;
+ my @methods = qw(
+ new
+ all
+ );
+
+ can_ok( $self->testing_class, @methods );
+}
+
+1;
diff --git a/t/lib/KohaTest/Message.pm b/t/lib/KohaTest/Message.pm
new file mode 100644
index 0000000..d1d822f
--- /dev/null
+++ b/t/lib/KohaTest/Message.pm
@@ -0,0 +1,52 @@
+package KohaTest::Message;
+use base qw( KohaTest );
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use C4::Message;
+sub testing_class { 'C4::Message' };
+
+
+sub methods : Test( 1 ) {
+ my $self = shift;
+ my @methods = qw(
+ new
+ find
+ find_last_message
+ enqueue
+ update
+ metadata
+ render_metadata
+ append
+ );
+
+ can_ok( $self->testing_class, @methods );
+}
+
+sub test_metadata : Test( 1 ) {
+ my $self = shift;
+ my $message = C4::Message->new;
+ $message->metadata({
+ header => "Header",
+ body => [],
+ footer => "Footer",
+ });
+ like($message->{metadata}, qr{^---}, "The metadata attribute should be serialized as YAML.");
+}
+
+sub test_append : Test( 1 ) {
+ my $self = shift;
+ my $message = C4::Message->new;
+ $message->metadata({
+ header => "Header",
+ body => [],
+ footer => "Footer",
+ });
+ $message->append("foo");
+ is($message->metadata->{body}->[0], "foo", "Appending a string should add an element to metadata.body.");
+}
+
+1;
--
1.5.5.GIT
More information about the Koha-patches
mailing list