| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XAO::testcases::FS::linkage; |
|
2
|
1
|
|
|
1
|
|
656
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
3
|
1
|
|
|
1
|
|
467
|
use XAO::Utils; |
|
|
1
|
|
|
|
|
18827
|
|
|
|
1
|
|
|
|
|
75
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use base qw(XAO::testcases::FS::base); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
510
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub test_linkage { |
|
8
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
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
|
|
0
|
|
|
|
$self->assert(ref($global) && $global->get('project'), |
|
28
|
|
|
|
|
|
|
"Got wrong global object from List"); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub test_uri { |
|
32
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
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; |