File Coverage

inc/WebService/Cmis/Test/Client.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package WebService::Cmis::Test::Client;
2 1     1   697 use base qw(WebService::Cmis::Test);
  1         2  
  1         606  
3             use Test::More;
4              
5             use strict;
6             use warnings;
7              
8             use Error qw(:try);
9             use WebService::Cmis::ClientException ();
10              
11             my $connection = $ENV{CMIS_CONNECTION} || $WebService::Cmis{DefaultConnection};
12             diag("connection = '$connection' ... set the enviromnent variable CMIS_CONNECTION to a different to test against a different backend");
13              
14              
15             sub test_login : Test(1) {
16             my $this = shift;
17              
18             my $client = $this->getClient;
19             my $ticket = $client->login;
20              
21             ok(defined $ticket);
22             }
23              
24             sub test_logout : Test(1) {
25             my $this = shift;
26              
27             my $client = $this->getClient;
28             my $ticket = $client->login;
29              
30             ok(defined $ticket);
31              
32             $client->logout;
33             $this->{client} = undef;
34              
35             # SMELL: how can we test we are logged out?
36             }
37              
38              
39             sub test_reuse_ticket : Test(2) {
40             my $this = shift;
41            
42             my $client1 = $this->getClient;
43             my $ticket1 = $client1->login;
44              
45             SKIP: {
46             skip "no ticket authentication", 2 unless $ticket1;
47              
48             note("ticket1=$ticket1");
49              
50             my $client2 = $this->getClient();
51             my $ticket2 = $client2->login(ticket=>$ticket1);
52             note("ticket2=$ticket2");
53              
54             ok($ticket2);
55              
56             is($ticket1, $ticket2);
57             }
58             }
59              
60             sub test_cant_reuse_after_logout : Test(1) {
61             my $this = shift;
62              
63             my $client = $this->getClient;
64              
65             $client->logout;
66             $this->{client} = undef;
67              
68             my $error = 0;
69             try {
70             $client->getRepositories;
71             } catch WebService::Cmis::ClientException with {
72             $error = 1;
73             note("it is okay to get a ".shift);
74             };
75              
76             ok($error, "we should not be able to use the client after having logged out");
77             }
78              
79             sub test_Client_getRepositories : Test(3) {
80             my $this = shift;
81              
82             my $client = $this->getClient;
83             my $repositories = $client->getRepositories;
84              
85             my $nrRepos = scalar(keys %$repositories);
86             note("found $nrRepos repository(ies)");
87             ok(scalar($nrRepos) > 0) or diag("can't find at least one repository");
88              
89             my ($repo) = (values %$repositories);
90             my $info = $repo->getRepositoryInfo;
91              
92             note("available info: ".join(", ", keys %$info));
93              
94             # SMELL: what's the absolute minimum?
95             foreach my $key (qw(repositoryName repositoryId)) {
96             note("$key=$info->{$key}");
97             ok(defined $info->{$key});
98             }
99             }
100              
101             sub test_Client_getDefaultRepository : Test(2) {
102             my $this = shift;
103              
104             my $repo = $this->getRepository;
105              
106             ok(defined $repo) or diag("can't find default repository");
107             isa_ok($repo, "WebService::Cmis::Repository");
108             }
109              
110             1;