/usr/share/perl5/Class/DBI/Lite/Fixture.pm is in libclass-dbi-lite-perl 1.026-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | package Class::DBI::Lite::Fixture;
use strict;
use warnings 'all';
my @destroys = ( );
my $_instance;
sub import
{
my ($class, @fixtures) = @_;
$_instance ||= bless { }, $class;
map {
my $setup = "setup_$_";
my $destroy = "destroy_$_";
push @destroys, sub { $class->$destroy };
$class->$setup
} @fixtures;
}# end import()
DESTROY
{
map { eval { $_->() } } @destroys;
}# end DESTROY()
1;# return true:
=pod
=head1 NAME
Class::DBI::Lite::Fixture - Test fixtures for easy testing.
=head1 SYNOPSIS
=head2 In Your Test Fixture
package app::fixtures;
use strict;
use warnings 'all';
use base 'Class::DBI::Lite::Fixture';
use app::state;
my @state_info = qw( AL:Alabama AK:Alaska AR:Arkansas );
my @states = ( );
sub setup_states {
push @states, map {
my ($abbr, $name) = split /\:/, $_;
app::state->find_or_create(
name => $name,
abbr => $abbr,
)
} @state_info;
}# end setup_states()
sub destroy_states {
map { eval{$_->delete} } @states;
}# end destroy_states()
1;# return true:
=head2 In Your Test File
use strict;
use warnings 'all';
use Test::More 'no_plan';
use lib qw( lib t/lib );
# Setup your test fixtures:
use app::fixtures 'states';
use_ok('app::state');
is(
app::state->count_search(abbr => 'AL') => 1
);
# The 'app::state' records are automatically deleted in 'destroy_states'!
=head1 DESCRIPTION
This module provides stubs for the use of "test fixtures" to test your code.
=head1 AUTHOR
Copyright John Drago <jdrago_999@yahoo.com>. All rights reserved.
=head1 LICENSE
This software is Free software and may be used and redistributed under the
same terms as perl itself.
=cut
|