Tests for New Modules

- KohaTest::Category
- KohaTest::ItemCirculationAlertPreference
- KohaTest::ItemType
- KohaTest::Message

Signed-off-by: Daniel Sweeney <daniel.sweeney@liblime.com>
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
John Beppu 2009-02-03 16:02:10 -06:00 committed by Galen Charlton
parent 39d0ed3635
commit ed3c0545da
4 changed files with 125 additions and 0 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

52
t/lib/KohaTest/Message.pm Normal file
View file

@ -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;