Apache-Voodoo

 view release on metacpan or  search on metacpan

t/Application.t  view on Meta::CPAN

use strict;
use warnings;

use lib("t");

use File::Copy;

use Test::More tests => 27;
use Data::Dumper;

BEGIN {
	# fall back to eq_or_diff if we don't have Test::Differences
	if (!eval q{ use Test::Differences; 1 }) {
		*eq_or_diff = \&is_deeply;
	}
}

use_ok('Apache::Voodoo::Constants')   || BAIL_OUT($@);
use_ok('Apache::Voodoo::Application') || BAIL_OUT($@);

my $path = $INC{'Apache/Voodoo/Constants.pm'};
$path =~ s:(blib/)?lib/Apache/Voodoo/Constants.pm:t:;

my $constants = Apache::Voodoo::Constants->new('test_data::MyConfig');
$constants->{INSTALL_PATH} = $path;

my $app;
eval {
	$app = Apache::Voodoo::Application->new();
};
ok($@ =~ /ID is a required parameter/, "ID is a required param") || diag $@;

eval {
	$app = Apache::Voodoo::Application->new('app_blank');
};
ok(!$@,'ID alone works') || diag($@);

eval {
	$app = Apache::Voodoo::Application->new('app_oldstyle',$constants);
};
ok(!$@,'ID and constants object works') || diag($@);

isa_ok($app->{'controllers'}->{'test_module'},            "Apache::Voodoo::Loader::Dynamic");
isa_ok($app->{'controllers'}->{'test_module'}->{'object'},"app_newstyle::test_module");

isa_ok($app->{'controllers'}->{'skeleton'},            "Apache::Voodoo::Loader::Dynamic");
isa_ok($app->{'controllers'}->{'skeleton'}->{'object'},"app_newstyle::skeleton");


#
# make sure the .pms are the original ones.
#
$path .= "/app_newstyle";
copy("$path/C/a/controller.pm.orig","$path/C/a/controller.pm") || die "can't reset controller.pm: $!";
copy("$path/M/a/model.pm.orig",     "$path/M/a/model.pm")      || die "can't reset model.pm: $!";
copy("$path/V/a/view.pm.orig",      "$path/V/a/view.pm")       || die "can't reset view.pm: $!";

eval {
	$app = Apache::Voodoo::Application->new('app_newstyle',$constants);
};
ok(!$@,'New style config works') || diag($@);

#
# check the controllers



( run in 0.481 second using v1.01-cache-2.11-cpan-39bf76dae61 )