Skip to content

Commit

Permalink
OtterTest::Class->object_accessor()
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gray committed Feb 9, 2015
1 parent 7969162 commit a78ba37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions t/lib/OtterTest/Class.pm
Expand Up @@ -113,6 +113,17 @@ sub constructor : Test(3) {
return;
}

# To be used by tests on accessors which return another object
# Runs 2 tests
sub object_accessor {
my ($test, $accessor, $expected_class, @args) = @_;
my $object = $test->our_object;
can_ok $object, $accessor;
$object = $object->$accessor(@args);
isa_ok $object, $expected_class, '... and returned object';
return $object;
}

sub test_attributes : Tests {
my $test = shift;
return 'abstract base class' if $test->is_abstract;
Expand Down
8 changes: 4 additions & 4 deletions t/lib/Test/Bio/Otter/Lace/CloneSequence.pm
Expand Up @@ -24,7 +24,7 @@ sub build_attributes {
super_contig_name => 'Super-Contig-Name', # redundant accessor?
pipeline_chromosome => 'Pipe-Chr', # redundant accessor?
ContigInfo => sub { return Test::Bio::Vega::ContigInfo->new->test_object },
pipelineStatus => sub { return bless {}, 'Bio::OtterLace::PipelineStatus' },
pipelineStatus => sub { return bless {}, 'Bio::Otter::Lace::PipelineStatus' },
};
}

Expand All @@ -46,12 +46,12 @@ sub accession_dot_sv : Test(2) {
return;
}

sub drop_pipelineStatus : Test(3) {
sub drop_pipelineStatus : Test(4) {
my $test = shift;
$test->set_attributes;
my $pls = $test->object_accessor( pipelineStatus => 'Bio::Otter::Lace::PipelineStatus' );
my $cs = $test->our_object;
can_ok $cs, 'drop_pipelineStatus';
$test->set_attributes;
isa_ok $cs->pipelineStatus, 'Bio::OtterLace::PipelineStatus', '...and when pipelineStatus';
$cs->drop_pipelineStatus;
is $cs->pipelineStatus, undef, '...it can be dropped';
return;
Expand Down

0 comments on commit a78ba37

Please sign in to comment.