Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Copyright (C) 2012 ByWater Solutions |
6 |
# Copyright (C) 2013 Equinox Software, Inc. |
7 |
# |
8 |
# Koha is free software; you can redistribute it and/or modify it |
9 |
# under the terms of the GNU General Public License as published by |
10 |
# the Free Software Foundation; either version 3 of the License, or |
11 |
# (at your option) any later version. |
12 |
# |
13 |
# Koha is distributed in the hope that it will be useful, but |
14 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
# GNU General Public License for more details. |
17 |
# |
18 |
# You should have received a copy of the GNU General Public License |
19 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
20 |
|
21 |
use Modern::Perl; |
22 |
|
23 |
use Getopt::Long qw( GetOptions ); |
24 |
use Pod::Usage qw( pod2usage ); |
25 |
|
26 |
use t::lib::TestBuilder; |
27 |
my $builder = t::lib::TestBuilder->new; |
28 |
|
29 |
my $source; |
30 |
my $values; |
31 |
my $number; |
32 |
my $help; |
33 |
my $verbose; |
34 |
|
35 |
GetOptions( |
36 |
"s|source=s" => \$source, |
37 |
"d|data=s%" => \$values, |
38 |
"n|number=i" => \$number, |
39 |
"h|help" => \$help, |
40 |
"v|verbose" => \$verbose, |
41 |
); |
42 |
|
43 |
# If we were asked for usage instructions, do it |
44 |
pod2usage(1) if $help || !$number || !$source; |
45 |
|
46 |
for ( 1 .. $number ) { |
47 |
$builder->build( |
48 |
{ |
49 |
source => $source, |
50 |
value => $values, |
51 |
} |
52 |
); |
53 |
} |
54 |
|
55 |
=head1 NAME |
56 |
|
57 |
misc/devel/create_test_data.pl |
58 |
|
59 |
=head1 SYNOPSIS |
60 |
|
61 |
create_test_data.pl -n 99 -s ObjectName [ -d foreignkey=somevalue ] |
62 |
|
63 |
This script allows for quickly generated large numbers of test data for development purposes. |
64 |
|
65 |
=head1 OPTIONS |
66 |
|
67 |
=over 8 |
68 |
|
69 |
=item B<-s|--source> <source> |
70 |
|
71 |
The DBIx::Class ResultSet source to use ( e.g. Branch, Category, EdifactMessage, etc. ) |
72 |
|
73 |
=item B<-d|--data> <valumn>=<value> |
74 |
|
75 |
Repeatable, set a given column to the specificed value for all generated data. |
76 |
|
77 |
create_test_data.pl -n 5 -s Issue -d borrowernumber=42 -d -d branchcode=MPL |
78 |
|
79 |
=item B<-n|--number> <number> |
80 |
|
81 |
The number of rows to create |
82 |
|
83 |
=item B<-h|--help> |
84 |
|
85 |
prints this help text |
86 |
|
87 |
=back |