forked from eprints/eprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.pl.disabled
executable file
·37 lines (26 loc) · 1.32 KB
/
email.pl.disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w
use Test::More tests => 9;
use TestLib;
use EPrints;
use Test::MockObject;
use strict;
#
my $mock_repository;
$mock_repository = Test::MockObject->new();
$mock_repository->set_always( 'get_conf', sub { return 1; } );
ok( EPrints::Utils::send_mail( $mock_repository, 'en','Bob Smith','[email protected]','test',undef,undef),
"sending mail returned true on success" );
$mock_repository = Test::MockObject->new();
$mock_repository->set_true( 'log' );
$mock_repository->set_always( 'get_conf', sub { return 0; } );
ok( !EPrints::Utils::send_mail( $mock_repository, 'en','Bob Smith','[email protected]','test subject',undef,undef),
"sending mail returned false on failure" );
my @args = $mock_repository->call_args( 2 );
$mock_repository->called_ok( 'log' );
is( $args[0], $mock_repository, "log to correct repository" );
ok( index($args[1],'Failed to send mail')!=-1, 'Failure causes warning to be logged' );
ok( index($args[1],'Bob Smith')!=-1, 'Warning mentions name' );
ok( index($args[1],'[email protected]')!=-1, 'Warning mentions email' );
ok( index($args[1],'test subject')!=-1, 'Warning mentions subject' );
my $date = EPrints::Utils::email_date();
ok( $date =~ m/(Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d\d? (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ , 'email_date()' );