[Cpan-forum-commit] rev 165 - in trunk: . lib/CPAN t/lib/CPAN/Forum t/mech
svn at pti.co.il
svn at pti.co.il
Fri Aug 25 18:15:06 IDT 2006
Author: gabor
Date: 2006-08-25 18:15:06 +0300 (Fri, 25 Aug 2006)
New Revision: 165
Modified:
trunk/
trunk/lib/CPAN/Forum.pm
trunk/t/lib/CPAN/Forum/Test.pm
trunk/t/mech/011-register.t
Log:
more tests, add hook for testing e-mail
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10992
+ 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10993
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2006-08-25 15:15:01 UTC (rev 164)
+++ trunk/lib/CPAN/Forum.pm 2006-08-25 15:15:06 UTC (rev 165)
@@ -927,7 +927,7 @@
Subject => $subject,
Message => $message,
);
- sendmail(%mail);
+ $self->_my_sendmail(%mail);
}
sub notify_admin {
@@ -947,7 +947,7 @@
Subject => "New Forum user: " . $user->username,
Message => $msg,
);
- sendmail(%mail);
+ $self->_my_sendmail(%mail);
}
sub pwreminder {
@@ -1000,7 +1000,7 @@
Subject => $subject,
Message => $message,
);
- sendmail(%mail);
+ $self->_my_sendmail(%mail);
return $self->pwreminder({"done" => 1});
}
@@ -2151,7 +2151,7 @@
Subject => $subject,
Message => $message,
);
- #sendmail(%mail);
+ #$self->_my_sendmail(%mail);
@@ -2195,7 +2195,7 @@
sub _sendmail {
my ($self, $it, $mail, $to, $ids) = @_;
-
+
while (my $s = $it->next) {
my $email = $s->uid->email;
$self->log->debug("Sending to $email ?");
@@ -2207,7 +2207,7 @@
next if $_[2]->{$email}++;
$self->log->debug("Sending to $email first time sending");
#warn "Yes, Sending to $email\n";
- sendmail(%$mail);
+ $self->_my_sendmail(%$mail);
$self->log->debug("Sent to $email");
}
}
@@ -2271,6 +2271,19 @@
}
}
+sub _my_sendmail {
+ my ($self, @args) = @_;
+
+ # for testing
+ if (defined &_test_my_sendmail) {
+ $self->_test_my_sendmail(@_);
+ return;
+ }
+ else {
+ return sendmail(@args);
+ }
+}
+
1;
=head1 ACKNOWLEDGEMENTS
Modified: trunk/t/lib/CPAN/Forum/Test.pm
===================================================================
--- trunk/t/lib/CPAN/Forum/Test.pm 2006-08-25 15:15:01 UTC (rev 164)
+++ trunk/t/lib/CPAN/Forum/Test.pm 2006-08-25 15:15:06 UTC (rev 165)
@@ -2,12 +2,6 @@
use File::Copy qw(copy);
-#require Exporter;
-#use vars qw(@ISA @EXPORT);
-#@ISA = qw(Exporter);
-
-#@EXPORT = qw(@users);
-
my $ROOT = "blib";
our @users = (
Modified: trunk/t/mech/011-register.t
===================================================================
--- trunk/t/mech/011-register.t 2006-08-25 15:15:01 UTC (rev 164)
+++ trunk/t/mech/011-register.t 2006-08-25 15:15:06 UTC (rev 165)
@@ -9,6 +9,7 @@
use lib qw(t/lib);
use CPAN::Forum::Test;
+my @users = @CPAN::Forum::Test::users;
{
CPAN::Forum::Test::setup_database();
@@ -88,55 +89,73 @@
BEGIN { $tests += 2*4; }
}
-__END__
-# reject bad usernames
+# reject bad email address
foreach my $email ("adb-?", "Abcde", "asd'er", "ab cd") {
- my $r = $cat->cgiapp(path_info => '/', params => {rm => 'register_process', nickname => "abcde", email => $email});
- like($r, qr{Registration Page});
- like($r, qr{Email must be a valid address writen in lower case letters});
+ $w->submit_form(
+ fields => {
+ nickname => "abcde",
+ email => $email,
+ },
+ );
+ $w->content_like(qr{Registration Page});
+ $w->content_like(qr{Email must be a valid address writen in lower case letters});
+ BEGIN { $tests += 2*4; }
}
+
+
+
my $pw;
my $password;
my $sendmail_count;
# register user
-{
- no warnings;
- sub CPAN::Forum::sendmail {
- my %mail = @_;
- #use Data::Dumper;
- #print STDERR Dumper \%mail;
- #print STDERR
- if ($mail{Message} =~ /your password is: (\w+)/) {
- $password = $1;
- }
- $sendmail_count++;
+sub CPAN::Forum::_test_my_sendmail {
+ my %mail = @_;
+ #use Data::Dumper;
+ #print STDERR Dumper \%mail;
+ #print STDERR
+ if ($mail{Message} =~ /your password is: (\w+)/) {
+ $password = $1;
}
- use warnings;
+ $sendmail_count++;
}
+
# TODO: check if the call to submail contains the correct values
{
$sendmail_count = 0;
$password = '';
- my $r = $cat->cgiapp(path_info => '/',
- params => {rm => 'register_process', nickname => $users[0]{username}, email => $users[0]{email}});
- like($r, qr{Registration Page});
- like($r, qr{Thank you for registering});
+ $w->submit_form(
+ fields => {
+ nickname => $users[0]{username},
+ email => $users[0]{email},
+ },
+ );
+ $w->content_like(qr{Registration Page});
+ $w->content_like(qr{Thank you for registering});
like($password, qr{\w{5}});
is($sendmail_count, 2);
$pw = $password;
+
+ BEGIN { $tests += 4; }
}
# try to register the same user again and see it fails
{
$sendmail_count = 0;
$password = '';
- my $r = $cat->cgiapp(path_info => '/',
- params => {rm => 'register_process', nickname => $users[0]{username}, email => $users[0]{email}});
- like($r, qr{Registration Page});
- like($r, qr{Nickname or e-mail already in use});
+ $w->back;
+ $w->submit_form(
+ fields => {
+ nickname => $users[0]{username},
+ email => $users[0]{email},
+ },
+ );
+ $w->content_like(qr{Registration Page});
+ $w->content_like(qr{Nickname or e-mail already in use});
is($sendmail_count, 0);
is($password, "");
+
+ BEGIN { $tests += 4; }
}
More information about the Cpan-forum-commit
mailing list