KiokuDB/Test/Fixture/GIN/Class.pm

filter: Statementstmt 100% 52 / 52 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 1 totaltotal 98.4% 63 / 64 CC 2 SCAR 1.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« KiokuDB/TypeMap/Default/Canonical.pm ↑ Summary KiokuDB/TypeMap/Entry/JSON/Scalar.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Test::Fixture::GIN::Class;
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::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Search::GIN::Query::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 extends qw(KiokuDB::Test::Fixture::Small);
15  
16 2 ▶use constant required_backend_roles => qw(Clear Scan Query::GIN);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 before populate => sub {
19 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 $self->backend->clear;
21 2 };
22  
23 sub verify {
24 1 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
25  
26 1 my $q_person = Search::GIN::Query::Class->new( class => "KiokuDB::Test::Person" );
27 1 my $q_employee = Search::GIN::Query::Class->new( class => "KiokuDB::Test::Employee" );
28  
29 $self->txn_lives(sub {
30 1 ▶ my @objs = $self->root_set->all;
Subroutine __ANON__: called CC=2 SCAR=6.9
31  
32 1 my $people = $self->search($q_person);
33 1 my $employees = $self->search($q_employee);
34  
35 1 does_ok($_, "Data::Stream::Bulk") for ( $people, $employees );
36  
37 1 my @people = $people->all;
38 1 my @employees = $employees->all;
39  
40 is_deeply(
41 1 [ sort map { refaddr($_) } @employees ],
42 [ refaddr($self->lookup_ok($self->joe)) ],
43 "employees",
44 );
45  
46 is_deeply(
47 3 [ sort map { refaddr($_) } @people ],
48 1 [ sort map { refaddr($_) } @objs, @{ $self->lookup_ok($self->joe)->parents } ],
49 "set of all people",
50 );
51 1 });
52  
53 1 $self->no_live_objects;
54  
55 $self->txn_lives(sub {
56 1 ▶ my ( $joe, $mum, $oscar ) = sort { $a->name cmp $b->name } $self->search($q_person)->all;
Subroutine __ANON__: called CC=1 SCAR=0.0
57  
58 1 is( $joe->name, "joe", "loaded first object" );
59 1 is( $mum->name, "mum", "loaded second object" );
60 1 is( $oscar->name, "oscar", "loaded third object" );
61  
62 1 is( $joe->parents->[0], $mum, "interrelated objects loaded in one graph" );
63 1 });
64  
65 1 $self->no_live_objects;
66 }
67  
68 2 __PACKAGE__->meta->make_immutable;
69  
70 2 __PACKAGE__
71  
72 __END__
« KiokuDB/TypeMap/Default/Canonical.pm ↑ Summary KiokuDB/TypeMap/Entry/JSON/Scalar.pm »