CMS-Drupal-Modules-MembershipEntity
view release on metacpan or search on metacpan
t/65_membership_object_functions.t view on Meta::CPAN
#! perl
use strict;
use warnings;
BEGIN {
## Make sure we don't connect to our real DB if we
## have given the credentials for it
$ENV{'DRUPAL_IGNORE_TEST_CREDS'} = 1;
}
use Test::More tests => 1;
use Test::Group;
use CMS::Drupal;
use CMS::Drupal::Modules::MembershipEntity;
use CMS::Drupal::Modules::MembershipEntity::Test;
my $drupal = CMS::Drupal->new;
my $dbh = build_test_db( $drupal );
my $ME = CMS::Drupal::Modules::MembershipEntity->new( dbh => $dbh );
# test the object functions
subtest 'Test a Membership object', sub {
my %params = (
'mid' => 666,
'member_id' => 999,
'type' => 'membership',
'status' => 1,
'uid' => 6996,
'created' => 1379916000,
'changed' => 1379987654,
'terms' => { 23456 => bless( {}, 'CMS::Drupal::Modules::MembershipEntity::Term' ) },
);
my $mem = CMS::Drupal::Modules::MembershipEntity::Membership->new( %params );
isa_ok( $mem, 'CMS::Drupal::Modules::MembershipEntity::Membership',
'Created a Membership object ' );
subtest 'Check static properties', sub {
plan tests => 8;
foreach my $prop (keys %params) {
is( $mem->{ $prop }, $params{ $prop }, $prop );
}
};
subtest 'can_ok methods', sub {
plan tests => 2;
foreach my $method ( qw/ is_active has_renewal / ) {
can_ok( $mem, $method );
}
};
subtest 'Validate methods', sub {
plan tests => 7;
is( $mem->is_active, 1, 'is_active when status = 1' );
for (0, 2, 3) {
$mem->{'status'} = $_;
isnt( $mem->is_active, 1, 'not is_active when status = '. $_ );
}
$mem->{'terms'} = {
'4088' => bless( {
( run in 0.831 second using v1.01-cache-2.11-cpan-39bf76dae61 )