KiokuDB/Test/Fixture/Small.pm

filter: Statementstmt 100% 62 / 62 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 4 totaltotal 95.0% 76 / 80 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« KiokuDB/Backend/Role/Query/Simple/Linear.pm ↑ Summary KiokuDB/TypeMap/Default/JSON.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Test::Fixture::Small;
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Test::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use KiokuDB::Test::Person;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use KiokuDB::Test::Employee;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use KiokuDB::Test::Company;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 sub p;
16  
17 2 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 sub p {
20 my @args = @_;
21 unshift @args, "name" if @args % 2;
22 KiokuDB::Test::Person->new(@args);
23 }
24  
25 2 with qw(KiokuDB::Test::Fixture) => { excludes => [qw/populate sort/] };
26  
27 22 ▶sub sort { -100 }
Subroutine sort: called CC=1 SCAR=0.0
Pod undocumented
28  
29 2 has [qw(joe oscar)] => (
30 isa => "Str",
31 is => "rw",
32 );
33  
34 sub create {
35 return (
36 67 ▶ KiokuDB::Test::Employee->new(
Subroutine create: called CC=1 SCAR=0.0
Pod undocumented
37 name => "joe",
38 age => 52,
39 parents => [ KiokuDB::Test::Person->new(
40 name => "mum",
41 age => 78,
42 ) ],
43 company => KiokuDB::Test::Company->new(
44 name => "OHSOME SOFTWARE KTHX"
45 ),
46 ),
47 KiokuDB::Test::Person->new(
48 name => "oscar",
49 age => 3,
50 ),
51 );
52 }
53  
54 sub populate {
55 67 ▶ my $self = shift;
Subroutine populate: called CC=1 SCAR=0.0
Pod undocumented
56  
57 {
58 67 my $s = $self->new_scope;
59  
60 67 my ( $joe, $oscar ) = $self->create;
61  
62 67 isa_ok( $joe, "KiokuDB::Test::Person" );
63 67 isa_ok( $joe, "KiokuDB::Test::Employee" );
64  
65 67 isa_ok( $oscar, "KiokuDB::Test::Person" );
66  
67 67 my ( $joe_id, $oscar_id ) = $self->store_ok($joe, $oscar);
68  
69 67 $self->joe($joe_id);
70 67 $self->oscar($oscar_id);
71  
72 67 $self->live_objects_are($joe, $joe->company, @{ $joe->parents }, $oscar);
73 }
74  
75 67 $self->no_live_objects;
76 }
77  
78 sub verify {
79 33 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
80  
81 $self->txn_lives(sub {
82 33 ▶ my ( $joe, $oscar ) = my @objs = $self->lookup_ok( $self->joe, $self->oscar );
Subroutine __ANON__: called CC=1 SCAR=0.0
83  
84 33 isa_ok( $joe, "KiokuDB::Test::Person" );
85 33 isa_ok( $joe, "KiokuDB::Test::Employee" );
86  
87 33 isa_ok( $oscar, "KiokuDB::Test::Person" );
88  
89 33 my $entry = $self->directory->live_objects->object_to_entry($joe);
90  
91 33 ok( $entry->has_object, "entry is associated with object" );
92  
93 25 is( refaddr($entry->object), refaddr($joe), "the right object" );
94  
95 25 is( $joe->name, "joe", "name" );
96  
97 25 ok( my $parents = $joe->parents, "parents" );
98  
99 25 is( ref($parents), "ARRAY", "array ref" );
100  
101 25 is( scalar(@$parents), 1, "one parent" );
102  
103 25 isa_ok( $parents->[0], "KiokuDB::Test::Person" );
104  
105 25 is( $parents->[0]->name, "mum", "parent name" );
106  
107 25 ok( my $company = $joe->company, "company" );
108  
109 25 isa_ok( $company, "KiokuDB::Test::Company" );
110  
111 25 is( $oscar->name, "oscar", "name" );
112  
113 25 ▶ lives_ok { $self->directory->lookup("no_such_id") } "lookup of nonexistent ID is nonfatal";
Subroutine __ANON__: called CC=1 SCAR=0.0
114 33 });
115 }
116 2 __PACKAGE__
117  
118 __END__
« KiokuDB/Backend/Role/Query/Simple/Linear.pm ↑ Summary KiokuDB/TypeMap/Default/JSON.pm »