Bug 8649: Add unit test for C4::Search
[koha.git] / t / db_dependent / zebra_config.pl
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4 use File::Copy;
5 use File::Path qw(make_path);
6 use File::Find;
7 use File::Basename;
8 use File::Spec;
9
10 my $source = File::Spec->rel2abs('.');
11 my $destination = File::Spec->rel2abs('.') . "/t/db_dependent/data";
12
13 make_path("$destination/var/lock/zebradb");
14 make_path("$destination/var/lib/zebradb");
15 make_path("$destination/var/run/zebradb");
16
17 $ENV{'INSTALL_BASE'} = $destination;
18 $ENV{'__INSTALL_BASE__'} = $destination;
19
20 my @files = ( "$source/etc/koha-conf.xml" );
21
22 find(sub { push @files, $File::Find::name if ( -f $File::Find::name ); }, "$source/etc/zebradb");
23
24 foreach my $file (@files) {
25     my $target = "$file";
26     $target =~ s#$source#$destination#;
27     $target =~ s#etc/zebradb#etc/koha/zebradb#;
28     unlink($target);
29     make_path(dirname($target));
30     copy("$file", "$target");
31     system("perl $source/rewrite-config.PL $target");
32     if ($file =~ m/xml/) {
33         replace("$target", "$destination/intranet/templates", "$source/koha-tmpl/intranet-tmpl");
34     }
35 }
36
37
38 sub replace {
39     my ($file, $pattern, $replacement) = @_;
40     system("sed -i -e 's#$pattern#$replacement#' $file");
41 }