| 1 | package XAO::testcases::FS::linkage; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use XAO::Utils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use base qw(XAO::testcases::FS::base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | sub test_linkage { | ||||||||||||||||||||
| 8 | 0 | ▶ | my $self=shift; | ||||||||||||||||||
|
Subroutine
test_linkage: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 9 | 0 | my $odb=$self->get_odb; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 0 | my $customer=$odb->fetch('/Customers/c1'); | |||||||||||||||||||
| 12 | 0 | $self->assert($customer, "Can't load a customer"); | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 0 | $self->assert(defined($customer->can('container_object')), | |||||||||||||||||||
| 15 | "Can't call container_object() on FS::Hash object!"); | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | my $list=$customer->container_object; | |||||||||||||||||||
| 18 | 0 | $self->assert(ref($list), | |||||||||||||||||||
| 19 | "Can't get container_object for customer"); | ||||||||||||||||||||
| 20 | 0 | $self->assert($list->get('c2')->container_key eq 'c2', | |||||||||||||||||||
| 21 | "Something is wrong with the customers list"); | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | $self->assert(defined($list->can('container_object')), | |||||||||||||||||||
| 24 | "Can't call container_object() on FS::List object!"); | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | my $global=$list->container_object; | |||||||||||||||||||
| 27 | 0 | ▶ | $self->assert(ref($global) && $global->get('project'), | ||||||||||||||||||
|
Condition0%0/3
ref $global && $global->get('project')
MC/DC0%0/2
ref $global && $global->get('project')
ref $global
$global->get('project')
Truth table0%0/3
A && B
A= ref $globalB= $global->get('project')
| |||||||||||||||||||||
| 28 | "Got wrong global object from List"); | ||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub test_uri { | ||||||||||||||||||||
| 32 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
test_uri: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 33 | 0 | my $odb = $self->get_odb; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | ## | ||||||||||||||||||||
| 36 | # Creating deeper structure required for better tests. | ||||||||||||||||||||
| 37 | # | ||||||||||||||||||||
| 38 | 0 | $odb->fetch('/Customers/c1')->add_placeholder( | |||||||||||||||||||
| 39 | name => 'Orders', | ||||||||||||||||||||
| 40 | type => 'list', | ||||||||||||||||||||
| 41 | class => 'Data::Order', | ||||||||||||||||||||
| 42 | key => 'order_id', | ||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||
| 44 | 0 | my $orders=$odb->fetch('/Customers/c1/Orders'); | |||||||||||||||||||
| 45 | 0 | $orders->put(o1 => $orders->get_new()); | |||||||||||||||||||
| 46 | 0 | $orders->put(o2 => $orders->get_new()); | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | my $o1=$odb->fetch('/Customers/c1/Orders/o1'); | |||||||||||||||||||
| 49 | 0 | $self->assert(ref($o1), | |||||||||||||||||||
| 50 | "Can't get /Customers/c1/Orders/o1"); | ||||||||||||||||||||
| 51 | 0 | my $uri=$o1->uri; | |||||||||||||||||||
| 52 | 0 | $self->assert($uri eq '/Customers/c1/Orders/o1', | |||||||||||||||||||
| 53 | "Wrong uri() -- '$uri' ne '/Customers/c1/Orders/o1'"); | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | $orders=$o1->container_object; | |||||||||||||||||||
| 56 | 0 | $self->assert(ref($orders), | |||||||||||||||||||
| 57 | "Can't get container object from o1"); | ||||||||||||||||||||
| 58 | 0 | $uri = $orders->uri; | |||||||||||||||||||
| 59 | 0 | $self->assert($uri eq '/Customers/c1/Orders', | |||||||||||||||||||
| 60 | "Wrong uri() -- '$uri' ne '/Customers/c1/Orders'"); | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | my $c1=$orders->container_object(); | |||||||||||||||||||
| 63 | 0 | $self->assert(ref($c1), | |||||||||||||||||||
| 64 | "Can't get container_object() from Orders"); | ||||||||||||||||||||
| 65 | 0 | $uri=$c1->uri; | |||||||||||||||||||
| 66 | 0 | $self->assert($uri eq '/Customers/c1', | |||||||||||||||||||
| 67 | "Wrong uri() -- '$uri' ne '/Customers/c1'"); | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | my $customers=$c1->container_object; | |||||||||||||||||||
| 70 | 0 | $self->assert(ref($customers), | |||||||||||||||||||
| 71 | "Can't get container_object from c1"); | ||||||||||||||||||||
| 72 | 0 | $uri=$customers->uri; | |||||||||||||||||||
| 73 | 0 | $self->assert($uri eq '/Customers', | |||||||||||||||||||
| 74 | "Wrong uri() -- '$uri' ne '/Customers'"); | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | my $global=$customers->container_object(); | |||||||||||||||||||
| 77 | 0 | $self->assert(ref($global), | |||||||||||||||||||
| 78 | "Can't get container_object from Customers"); | ||||||||||||||||||||
| 79 | 0 | $uri=$global->uri; | |||||||||||||||||||
| 80 | 0 | $self->assert($uri eq '/', | |||||||||||||||||||
| 81 | "Wrong uri() -- '$uri' ne '/'"); | ||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 1 | 1; | |||||||||||||||||||