Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add tests for NewMail macro. Small refactoring for NewMail macro.
- Loading branch information
1 parent
d4ca728
commit 7b5b493
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#------------------------------------------------------------------- | ||
# WebGUI is Copyright 2001-2009 Plain Black Corporation. | ||
#------------------------------------------------------------------- | ||
# Please read the legal notices (docs/legal.txt) and the license | ||
# (docs/license.txt) that came with this distribution before using | ||
# this software. | ||
#------------------------------------------------------------------- | ||
# http://www.plainblack.com info@plainblack.com | ||
#------------------------------------------------------------------- | ||
|
||
use FindBin; | ||
use strict; | ||
use lib "$FindBin::Bin/../lib"; | ||
|
||
use WebGUI::Test; | ||
use WebGUI::Session; | ||
use WebGUI::Macro::NewMail; | ||
use WebGUI::Inbox; | ||
|
||
use Test::More; # increment this value for each test you create | ||
|
||
my $session = WebGUI::Test->session; | ||
|
||
my $numTests = 3; | ||
|
||
plan tests => $numTests; | ||
|
||
my $inboxUser = WebGUI::User->create($session); | ||
$session->user({userId => $inboxUser->getId}); | ||
addToCleanup($inboxUser); | ||
|
||
my $inbox = WebGUI::Inbox->new($session); | ||
|
||
is(WebGUI::Macro::NewMail::process($session), '', 'NewMail macro returns "" if user has no messages'); | ||
|
||
$inbox->addMessage( | ||
{ | ||
userId => $inboxUser->getId, | ||
subject => 'test message 1', | ||
message => 'test message 1', | ||
}, | ||
{ | ||
no_email => 1, | ||
}, | ||
); | ||
$inbox->addMessage( | ||
{ | ||
userId => $inboxUser->getId, | ||
subject => 'test message 2', | ||
message => 'test message 2', | ||
}, | ||
{ | ||
no_email => 1, | ||
}, | ||
); | ||
|
||
like( | ||
WebGUI::Macro::NewMail::process($session), | ||
qr{<a href=".+?op=account;module=inbox">.+?</a>}, | ||
q{... returns URL to view user's inbox} | ||
); | ||
|
||
like( | ||
WebGUI::Macro::NewMail::process($session, "cssClass"), | ||
qr{<a href=".+?op=account;module=inbox"\s+class="cssClass">.+?</a>}, | ||
q{... returns URL to view user's inbox} | ||
); |