File Coverage

blib/lib/Test/Shared/Fixture/Data/Message/Board/Example.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package Test::Shared::Fixture::Data::Message::Board::Example;
2              
3 8     8   1132196 use base qw(Data::Message::Board);
  8         18  
  8         4073  
4 8     8   53 use strict;
  8         12  
  8         160  
5 8     8   30 use warnings;
  8         32  
  8         311  
6              
7 8     8   4196 use Data::Message::Board::Comment;
  8         30  
  8         338  
8 8     8   4087 use Data::Person;
  8         1257423  
  8         954  
9 8     8   7866 use DateTime;
  8         4723196  
  8         2011  
10              
11             our $VERSION = 0.06;
12              
13             sub new {
14 6     6 1 1647188 my $class = shift;
15              
16 6         104 my @params = (
17             'author' => Data::Person->new(
18             'name' => 'John Wick',
19             ),
20             'comments' => [
21             Data::Message::Board::Comment->new(
22             'author' => Data::Person->new(
23             'name' => 'Gregor Herrmann',
24             ),
25             'date' => DateTime->new(
26             'day' => 25,
27             'month' => 5,
28             'year' => 2024,
29             'hour' => 17,
30             'minute' => 53,
31             'second' => 27,
32             ),
33             'id' => 1,
34             'message' => 'apt-get update; apt-get install perl;',
35             ),
36             Data::Message::Board::Comment->new(
37             'author' => Data::Person->new(
38             'name' => 'Emmanuel Seyman',
39             ),
40             'date' => DateTime->new(
41             'day' => 25,
42             'month' => 5,
43             'year' => 2024,
44             'hour' => 17,
45             'minute' => 53,
46             'second' => 37,
47             ),
48             'id' => 2,
49             'message' => 'dnf update; dnf install perl-intepreter;',
50             ),
51             ],
52             'date' => DateTime->new(
53             'day' => 25,
54             'month' => 5,
55             'year' => 2024,
56             'hour' => 17,
57             'minute' => 53,
58             'second' => 20,
59             ),
60             'id' => 7,
61             'message' => 'How to install Perl?',
62             );
63              
64 6         2081 my $self = $class->SUPER::new(@params);
65              
66 6         91 return $self;
67             }
68              
69             1;
70              
71             __END__
72              
73             =pod
74              
75             =encoding utf8
76              
77             =head1 NAME
78              
79             Test::Shared::Fixture::Data::Message::Board::Example - Data fixture via Data::Message::Board.
80              
81             =head1 SYNOPSIS
82              
83             use Test::Shared::Fixture::Data::Message::Board::Example;
84              
85             my $obj = Test::Shared::Fixture::Data::Message::Board::Example->new(%params);
86             my $author = $obj->author;
87             my $comments_ar = $obj->comments;
88             my $date = $obj->date;
89             my $id = $obj->id;
90             my $message = $obj->message;
91              
92             =head1 METHODS
93              
94             =head2 C<new>
95              
96             my $obj = Test::Shared::Fixture::Data::Message::Board::Example->new(%params);
97              
98             Constructor.
99              
100             Returns instance of object.
101              
102             =head2 C<author>
103              
104             my $author = $obj->author;
105              
106             Get author instance.
107              
108             Returns L<Data::Person> instance.
109              
110             =head2 C<comments>
111              
112             my $comments_ar = $obj->comments;
113              
114             Get message board comments.
115              
116             Returns reference to array with L<Data::Message::Board::Comment> instances.
117              
118             =head2 C<date>
119              
120             my $date = $obj->date;
121              
122             Get datetime of comment.
123              
124             Returns L<DateTime> instance.
125              
126             =head2 C<id>
127              
128             my $id = $obj->id;
129              
130             Get comment id.
131              
132             Returns natural number.
133              
134             =head2 C<>
135              
136             my $message = $obj->message;
137              
138             Get comment message.
139              
140             Returns string.
141              
142             =head1 EXAMPLE
143              
144             =for comment filename=fixture.pl
145              
146             use strict;
147             use warnings;
148              
149             use Test::Shared::Fixture::Data::Message::Board::Example;
150              
151             my $obj = Test::Shared::Fixture::Data::Message::Board::Example->new;
152              
153             # Print out.
154             print 'Author name: '.$obj->author->name."\n";
155             print 'Date: '.$obj->date."\n";
156             print 'Id: '.$obj->id."\n";
157             print 'Message: '.$obj->message."\n";
158             print "Comments:\n";
159             map {
160             print "\tAuthor name: ".$_->author->name."\n";
161             print "\tDate: ".$_->date."\n";
162             print "\tId: ".$_->id."\n";
163             print "\tComment: ".$_->message."\n\n";
164             } @{$obj->comments};
165              
166             # Output:
167             # Author name: John Wick
168             # Date: 2024-05-25T17:53:20
169             # Id: 7
170             # Message: How to install Perl?
171             # Comments:
172             # Author name: Gregor Herrmann
173             # Date: 2024-05-25T17:53:27
174             # Id: 1
175             # Comment: apt-get update; apt-get install perl;
176             #
177             # Author name: Emmanuel Seyman
178             # Date: 2024-05-25T17:53:37
179             # Id: 2
180             # Comment: dnf update; dnf install perl-intepreter;
181             #
182              
183             =head1 DEPENDENCIES
184              
185             L<Data::Message::Board>,
186             L<Data::Message::Board::Comment>,
187             L<Data::Person>,
188             L<DateTime>.
189              
190             =head1 REPOSITORY
191              
192             L<https://github.com/michal-josef-spacek/Data-Message-Board>
193              
194             =head1 AUTHOR
195              
196             Michal Josef Špaček L<mailto:skim@cpan.org>
197              
198             L<http://skim.cz>
199              
200             =head1 LICENSE AND COPYRIGHT
201              
202             © 2024-2025 Michal Josef Špaček
203              
204             BSD 2-Clause License
205              
206             =head1 VERSION
207              
208             0.06
209              
210             =cut