start fixing test for multi cat phenotype upload.
[sgn.git] / t / unit_fixture / SGN / SiteFeatures / crossreference.t
blob44d48ef05e225521d6b65875beaa10226d655e74
1 use strict;
2 use warnings;
4 use Test::More;
5 use Test::MockObject;
7 use_ok( 'SGN::SiteFeatures::CrossReference' );
9 my $mock_feature = Test::MockObject->new;
10 $mock_feature->set_always( 'feature_name', 'fakefeature' );
12 my $cr1 = SGN::SiteFeatures::CrossReference->new({
13     url  => '/foo/bar.txt',
14     text => 'Noggin',
15     feature => $mock_feature,
16 });
18 my $cr2 = SGN::SiteFeatures::CrossReference->new({
19     url  => '/foo/bar.txt',
20     text => 'Noggin',
21     feature => $mock_feature,
22 });
24 my $cr3 = SGN::SiteFeatures::CrossReference->new({
25     url  => '/foo/baz.txt',
26     text => 'Noggin',
27     feature => $mock_feature,
28 });
30 ok(   $cr2->cr_eq( $cr1 ), 'cr eq finds equal'     );
31 ok( ! $cr2->cr_eq( $cr3 ), 'cr eq finds not equal' );
33 is( $cr2->cr_cmp( $cr1 ),  0, 'cr cmp for eq' );
34 is( $cr2->cr_cmp( $cr3 ), -1, 'cr cmp 1' );
35 is( $cr3->cr_cmp( $cr1 ),  1, 'cr cmp 2' );
37 my @u = $cr1->uniq( $cr2, $cr3 );
38 is( scalar(@u), 2, 'uniq seems to work 0' );
39 is( $cr1,   $u[0], 'uniq seems to work 1' );
40 is( $cr3,   $u[1], 'uniq seems to work 2' );
42 my $js_hash = $cr3->TO_JSON;
43 is( $js_hash->{text}, 'Noggin' );
44 can_ok( $js_hash->{url}, 'scheme', 'path' );
45 is( $js_hash->{feature}, 'fakefeature' );
49 done_testing;