forked from wearerequired/digest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0904cfd
commit ca89083
Showing
1 changed file
with
123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
namespace Required\Digest\Tests; | ||
|
||
use \WP_UnitTestCase; | ||
use \Required\Digest\Message\CommentNotification as CommentNotificationMessage; | ||
|
||
class CommentNotification extends WP_UnitTestCase { | ||
public function test_no_entries() { | ||
$message = new CommentNotificationMessage( array() ); | ||
|
||
$this->assertContains( 'There were 0 new comments', $message->get_message() ); | ||
$this->assertNotContains( 'already moderated.', $message->get_message() ); | ||
} | ||
|
||
public function test_invalid_entry() { | ||
$message = new CommentNotificationMessage( array( | ||
'123' => time(), | ||
) ); | ||
|
||
$this->assertContains( 'There was 1 new comment', $message->get_message() ); | ||
$this->assertContains( '1 comment was already moderated.', $message->get_message() ); | ||
} | ||
|
||
public function test_already_processed_entry() { | ||
$comment_id = self::factory()->comment->create(); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
) ); | ||
|
||
$this->assertContains( 'There was 1 new comment', $message->get_message() ); | ||
} | ||
|
||
public function test_comment_action_links() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
) ); | ||
|
||
$user = self::factory()->user->create_and_get( array( | ||
'role' => 'administrator', | ||
'email' => '[email protected]', | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
), $user ); | ||
|
||
$this->assertNotContains( 'Approve', $message->get_message() ); | ||
$this->assertContains( 'Trash', $message->get_message() ); | ||
$this->assertContains( 'Spam', $message->get_message() ); | ||
} | ||
|
||
public function test_comment_action_links_no_capabilities() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
) ); | ||
|
||
$user = self::factory()->user->create_and_get( array( | ||
'role' => 'subscriber', | ||
'email' => '[email protected]', | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
), $user ); | ||
|
||
$this->assertNotContains( 'Trash', $message->get_message() ); | ||
$this->assertNotContains( 'Spam', $message->get_message() ); | ||
} | ||
|
||
public function test_pingback() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
'comment_type' => 'pingback', | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
) ); | ||
|
||
$this->assertContains( 'Pingback on ', $message->get_message() ); | ||
} | ||
|
||
public function test_trackback() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
'comment_type' => 'trackback', | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
) ); | ||
|
||
$this->assertContains( 'Trackback on ', $message->get_message() ); | ||
} | ||
|
||
public function test_comment_author_url() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
'comment_author_url' => 'http://example.com' | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
) ); | ||
|
||
$this->assertContains( 'http://example.com', $message->get_message() ); | ||
} | ||
|
||
public function test_comment_author_email() { | ||
$comment_id = self::factory()->comment->create( array( | ||
'comment_approved' => 0, | ||
'comment_author_email' => '[email protected]' | ||
) ); | ||
|
||
$message = new CommentNotificationMessage( array( | ||
$comment_id => time(), | ||
) ); | ||
|
||
$this->assertContains( '[email protected]', $message->get_message() ); | ||
} | ||
} |