Eve/RegistryStub.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Eve/HttpResourceGraphTestBase.pm ↑ Summary Eve/EventTestBase.pm »
1 package Eve::RegistryStub;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶no warnings qw(redefine);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Test::MockObject::Extends;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶use Eve::Registry;
Subroutine BEGIN: called CC=1 SCAR=2.6
11  
12 =head1 NAME
13  
14 B<Eve::RegistryStub> - a helper class that replaces the registry with
15 a mock object.
16  
17 =head1 SYNOPSIS
18  
19 package SomeTestCase;
20  
21 use Eve::RegistryStub;
22 use Eve::Registry;
23  
24 my $already_mocked_registry = Eve::Registry->new(
25 # some literals declarations);
26  
27 my $service = $registry->get_service();
28  
29 =head1 DESCRIPTION
30  
31 B<Eve::RegistryStub> is the mock version of a B<Eve::Registry> class
32 that contains all services and automatically replaces some input
33 parameter with bogus default values..
34  
35 =head1 METHODS
36  
37 =head2 B<main()>
38  
39 =cut
40  
41 sub main {
42 my $init = \&Eve::Registry::init;
43  
44 *Eve::Registry::new = sub {
45 my $self = &Eve::Class::new(@_);
46  
47 return Test::MockObject::Extends->new($self);
48 };
49  
50 *Eve::Registry::init = sub {
51 my $self = shift;
52  
53 $init->(
54 $self,
55 base_uri_string => 'http://example.com',
56 email_from_string => 'Someone <someone@example.com>',
57 session_storage_path => File::Spec->catdir(
58 File::Spec->tmpdir(), 'test_session_storage'),
59 session_expiration_interval => 3600,
60 @_);
61 };
62 }
63  
64 main();
65  
66 =head1 SEE ALSO
67  
68 =over 4
69  
70 =item L<Eve::Test>
71  
72 =item L<Test::Class>
73  
74 =back
75  
76 =head1 LICENSE AND COPYRIGHT
77  
78 Copyright 2010-2013 Sergey Konoplev, Igor Zinovyev.
79  
80 This program is free software; you can redistribute it and/or modify it
81 under the terms of either: the GNU General Public License as published
82 by the Free Software Foundation; or the Artistic License.
83  
84 See http://dev.perl.org/licenses/ for more information.
85  
86 =head1 AUTHOR
87  
88 =over 4
89  
90 =item L<Sergey Konoplev|mailto:gray.ru@gmail.com>
91  
92 =item L<Igor Zinovyev|mailto:zinigor@gmail.com>
93  
94 =back
95  
96 =cut
97  
98 1;
« Eve/HttpResourceGraphTestBase.pm ↑ Summary Eve/EventTestBase.pm »