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 |
|
48 |
if ( $source eq 'Biblio' ) { |
49 |
$builder->build_sample_biblio($values); |
50 |
} elsif ( $source eq 'Item' ) { |
51 |
$builder->build_sample_item($values); |
52 |
} elsif ( $source eq 'Illrequest' ) { |
53 |
$builder->build_sample_ill_request($values); |
54 |
} else { |
55 |
$builder->build( |
56 |
{ |
57 |
source => $source, |
58 |
value => $values, |
59 |
} |
60 |
); |
61 |
} |
62 |
} |
63 |
|
64 |
=head1 NAME |
65 |
|
66 |
misc/devel/create_test_data.pl |
67 |
|
68 |
=head1 SYNOPSIS |
69 |
|
70 |
create_test_data.pl -n 99 -s ObjectName [ -d foreignkey=somevalue ] |
71 |
|
72 |
This script allows for quickly generated large numbers of test data for development purposes. |
73 |
|
74 |
=head1 OPTIONS |
75 |
|
76 |
=over 8 |
77 |
|
78 |
=item B<-s|--source> <source> |
79 |
|
80 |
The DBIx::Class ResultSet source to use ( e.g. Branch, Category, EdifactMessage, etc. ) |
81 |
|
82 |
=item B<-d|--data> <valumn>=<value> |
83 |
|
84 |
Repeatable, set a given column to the specified value for all generated data. |
85 |
|
86 |
create_test_data.pl -n 5 -s Issue -d borrowernumber=42 -d -d branchcode=MPL |
87 |
|
88 |
=item B<-n|--number> <number> |
89 |
|
90 |
The number of rows to create |
91 |
|
92 |
=item B<-h|--help> |
93 |
|
94 |
prints this help text |
95 |
|
96 |
=back |