Apache-SWIT

 view release on metacpan or  search on metacpan

t/530_subsystem.t  view on Meta::CPAN

use strict;
use warnings FATAL => 'all';

use Test::More tests => 51;
use File::Temp qw(tempdir);
use Data::Dumper;
use Test::TempDatabase;
use YAML;
use File::Slurp;
use Apache::SWIT::Maker::Conversions;
use Apache::SWIT::Maker::Manifest;
use Cwd qw(abs_path getcwd);
use File::Basename qw(dirname);

use Apache::SWIT::Test::Utils;
use HTML::Tested::Value::Form;
use HTML::Tested::Value::Marked;

BEGIN { use_ok('Apache::SWIT::Subsystem::Maker');
	use_ok('Apache::SWIT::Test::ModuleTester');
	use_ok('Apache::SWIT::Test::Apache');
}

my $dn = abs_path("blib/lib");
my $mt = Apache::SWIT::Test::ModuleTester->new({ root_class => 'TTT' });
my $td = $mt->root_dir;
chdir $td;
$mt->run_modulemaker_and_chdir;
ok(-f 'LICENSE');

my $tttpm = read_file('lib/TTT.pm');
Apache::SWIT::Subsystem::Maker->new->write_initial_files();
is(-f './lib/TTT/DB/Connection.pm', undef);
is(-f './t/T/TTT/DB/Connection.pm', undef);
isnt(-f './t/001_load.t', undef);
is(-f 'lib/TTT/DB/Base.pm', undef);
is(read_file('lib/TTT.pm'), $tttpm);
like(read_file('Makefile.PL'),
	       	qr/Apache::SWIT::Subsystem::Makefile/);

swmani_write_file("lib/" . conv_class_to_file("TTT::DB::Random")
		, conv_module_contents("TTT::DB::Random", <<ENDF));
sub number { return 494; }
ENDF

$mt->replace_in_file('lib/' . $mt->module_dir . "/Session.pm", '1', <<ENDM);
sub swit_startup {
	my \$class = shift;
	\$class->add_var('username');
	\$class->add_var('t_ttt');
}

1;
ENDM

write_file("t/555_test.t", <<'ENDT');
use Test::More tests => 5;
BEGIN { use_ok('T::Test');
	use_ok('TTT::DB::Random');
}
is(TTT::DB::Random->number, 494);
is(TTT::Session->cookie_name, 'ttt');
can_ok(TTT::Session, 'get_t_ttt');
ENDT

my $tree = Apache::SWIT::Maker::Config->instance;



( run in 3.384 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )