App-Followme

 view release on metacpan or  search on metacpan

t/EditSections.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;

use File::Path qw(rmtree);
use File::Spec::Functions qw(catdir catfile rel2abs splitdir);

use Test::More tests => 11;

#----------------------------------------------------------------------
# Change the modification date of a file

sub age {
	my ($filename, $sec) = @_;
	return unless -e $filename;
	return if $sec <= 0;
	
    my @stats = stat($filename);
    my $date = $stats[9];
    $date -= $sec;
    utime($date, $date, $filename);
    
    return; 
}

#----------------------------------------------------------------------
# Load package

my @path = splitdir(rel2abs($0));
pop(@path);
pop(@path);

my $lib = catdir(@path, 'lib');
unshift(@INC, $lib);

eval "use App::Followme::FIO";
require App::Followme::EditSections;

my $test_dir = catdir(@path, 'test');

rmtree($test_dir, 0, 1) if -e $test_dir;
mkdir($test_dir) unless -e $test_dir;

my $sub_dir = catfile(@path, "test", "sub"); 
mkdir($sub_dir) unless -e $sub_dir;

chdir $test_dir or die $!;

my %configuration = (
                    top_directory => $test_dir,
                    base_directory => $test_dir,
                    remove_comments => 0,
                    data_pkg => 'App::Followme::WebData',
                    );

#----------------------------------------------------------------------
# Write test pages

do {
   my $page = <<'EOQ';
<html>
<head>
<meta name="robots" content="archive">
<!-- begin meta -->
<title>page %%</title>
<!-- end meta -->
</head>
<body>
<!-- begin content -->
<h1>page %%</h1>
<!-- end content -->
<ul>
<li><a href="">&& link</a></li>
<!-- begin nav -->
<li><a href="">link %%</a></li>
<!-- end nav -->
</ul>
</body>



( run in 1.027 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )