Apache-SWIT
view release on metacpan or search on metacpan
t/530_subsystem.t view on Meta::CPAN
$res = join('', `make test 2>&1`);
unlike($res, qr/Error/) or ASTU_Wait($td);
like($res, qr/success/);
like($res, qr/localhost/);
like($res, qr/950_install/);
unlike($res, qr/Please use/);
append_file('conf/startup.pl', '`touch $INC[0]/../../touched`; 1;' . "\n");
sleep 1;
system("echo ### >> conf/startup.pl");
sleep 1;
system("touch conf/startup.pl");
sleep 1;
$res = join('', `make test_apache 2>&1`);
like($res, qr/success/) or ASTU_Wait($res);
my $mf = read_file('Makefile');
like(read_file('blib/conf/startup.pl'), qr/touch/) or ASTU_Wait($mf . $res);
ok(-f 'touched');
ok(-f 't/dual/001_load.t');
append_file('t/dual/001_load.t', <<ENDS);
# \$t->ok_ht_userlist_r(make_url => 1, ht => {
# user_list => [ { ht_id => 1, name => 'admin' } ] });
# \$t->ok_ht_userform_r(make_url => 1, ht => {
# username => '', password => '', });
# HT_SEALED_ht_id => '1', name => 'admin', _role_name => 'admin'
ENDS
my $m_str2 = read_file('MANIFEST');
is($m_str2, $m_str);
$res = `make`;
is($?, 0) or ASTU_Wait;
$res = $mt->run_make_install;
is(-d "$td/inst/share/ttt", undef) or do {
# diag($res);
# diag("$td");
#readline(\*STDIN);
};
isnt(-d "$td/inst/share/perl", undef) or do {
## diag($res);
# diag("$td");
#readline(\*STDIN);
};
ok(-f $mt->install_dir . "/TTT.pm");
my $inst_path = $mt->install_dir . "/TTT";
ok(-f "$inst_path/Maker.pm");
my $idir = abs_path($mt->install_dir);
chdir $td;
$mt->make_swit_project(root_class => 'MU');
$mt->install_subsystem('TheSub');
ok(require 'TTT/Maker.pm');
eval "use lib 'lib'";
is(-f 'lib/MU/TheSub.pm', undef);
use_ok('HTML::Tested', qw(HT HTV));
isnt(-f "t/dual/thesub/001_load.t", undef) or ASTU_Wait($td);
my $s001 = read_file("t/dual/thesub/001_load.t");
like($s001, qr/ht_id/) or ASTU_Wait($mf);
like($s001, qr/HT_SEALED_ht_id/);
undef $Apache::SWIT::Maker::Config::_instance;
$tree = Apache::SWIT::Maker::Config->instance;
$ind = $tree->{pages}->{"thesub/index"};
isnt($ind, undef) or diag(Dumper($tree));
is($ind->{entry_points}->{r}->{template}, 'templates/thesub/index.tt');
is($ind->{entry_points}->{r}->{foo}, 'boo')
or diag(Dumper($tree));
is($ind->{class}, 'TTT::UI::Index');
is(read_file('templates/thesub/index.tt'),
read_file('templates/index.tt'));
symlink("$td/TTT/blib/lib/TTT", "blib/lib/TTT");
`perl Makefile.PL && make 2>&1`;
like(read_file('t/T/Test.pm'), qr/\bthesub\/index/);
$mt->replace_in_file('t/dual/001_load.t', '=> 11', '=> 12');
symlink("$td/TTT/blib/lib/TTT", "blib/lib/TTT") or die "# Unable to symlink";
append_file('t/dual/001_load.t', <<ENDT);
\$t->ok_ht_thesub_index_r(make_url => 1, ht => { first => '' });
ENDT
$ENV{PERL5LIB} = "$idir\:$dn";
if (!$<) {
for (my $d = $idir; $d ne '/tmp'; $d = dirname($d)) {
system("chmod a+rx $d") and die;
}
}
$res = join('', `echo \$PERL5LIB && make test 2>&1`);
unlike($res, qr/Error/) or ASTU_Wait($td);
like($res, qr/thesub\/001/);
chdir "$td/TTT";
$mt->insert_into_schema_pm('\$dbh->do("create table ttt_table (a text)")');
$mt->replace_in_file('lib/TTT/UI/Index.pm', "return \\\$", <<ENDM);
my \$arr = Apache::SWIT::DB::Connection->instance->db_handle
->selectcol_arrayref("select a from ttt_table");
\$r->pnotes('SWITSession')->set_username(\$arr);
return \$
ENDM
$mt->replace_in_file('t/dual/001_load.t', '=> 11', '=> 14');
append_file('t/dual/001_load.t', <<ENDT);
can_ok(\$t->session, 'get_username');
\$t->ok_ht_index_r(make_url => 1, ht => { first => '' });
\$t->ht_index_u(ht => {});
\$t->ok_ht_index_r(ht => { first => '' });
ENDT
$mt->replace_in_file('t/950_install.t', "TheSub'\\);", <<ENDM);
TheSub');
\$mt->install_subsystem_schema;
\$mt->install_session_base;
ENDM
( run in 1.444 second using v1.01-cache-2.11-cpan-39bf76dae61 )