File Coverage

blib/lib/Test/MockFile/DirHandle.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 12 12 100.0


line stmt bran cond sub pod time code
1             # Copyright (c) 2018, cPanel, LLC.
2             # All rights reserved.
3             # http://cpanel.net
4             #
5             # This is free software; you can redistribute it and/or modify it under the
6             # same terms as Perl itself. See L.
7              
8             package Test::MockFile::DirHandle;
9              
10 37     37   273 use strict;
  37         79  
  37         1182  
11 37     37   209 use warnings;
  37         104  
  37         3930  
12              
13             our $VERSION = '0.036';
14              
15             =head1 NAME
16              
17             Test::MockFile::DirHandle - Provides a class object for
18             L to give out for opendir calls.
19              
20             =head1 VERSION
21              
22             Version 0.036
23              
24             =cut
25              
26             =head1 SYNOPSIS
27              
28             This is a helper class for L its only purpose is to
29             provide a object to recognize that a the passed handle is a mocked
30             handle. L has to mock the other calls since there is no
31             tie for B handles.
32              
33             # This is what Test::MockFile does. You really shouldn't be doing it directly.
34             use Test::MockFile::DirHandle;
35             my $handle = Test::MockFile::DirHandle->new("/fake/path", [qw/. .. a bbb ccc dd/]);
36              
37             =head1 EXPORT
38              
39             No exports are provided by this module.
40              
41             =head1 SUBROUTINES/METHODS
42              
43             =head2 new
44              
45             Args: ($class, $dir, $files_array_ref)
46              
47             Returns a blessed object for Test::MockFile::DirHandle. There are no
48             error conditions handled here.
49              
50             B the permanent directory contents are stored in a hash in
51             Test::MockFile. However when opendir is called, a copy is stored here.
52             This is because through experimentation, we've determined that adding
53             files in a dir during a opendir/readdir does not affect the return of
54             readdir.
55              
56             See L.
57              
58             =cut
59              
60             sub new {
61 13     13 1 38 my ( $class, $dir, $files_in_readdir ) = @_;
62              
63 13         66 return bless {
64             files_in_readdir => $files_in_readdir,
65             'dir' => $dir,
66             'tell' => 0,
67             }, $class;
68             }
69              
70             =head1 AUTHOR
71              
72             Todd Rinaldo, C<< >>
73              
74             =head1 BUGS
75              
76             Please report any bugs or feature requests to
77             L.
78              
79             =head1 SUPPORT
80              
81             You can find documentation for this module with the perldoc command.
82              
83             perldoc Test::MockFile::DirHandle
84              
85             You can also look for information at:
86              
87             =over 4
88              
89             =item * CPAN Ratings
90              
91             L
92              
93             =item * Search CPAN
94              
95             L
96              
97             =back
98              
99             =head1 LICENSE AND COPYRIGHT
100              
101             Copyright 2018 cPanel L.L.C.
102              
103             All rights reserved.
104              
105             L
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as Perl itself. See L.
109              
110             =cut
111              
112             1;