Skip to content

Instantly share code, notes, and snippets.

@kurtpayne
Created April 12, 2012 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtpayne/2369072 to your computer and use it in GitHub Desktop.
Save kurtpayne/2369072 to your computer and use it in GitHub Desktop.
Ajax exception timestamp assertions
Index: wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php
===================================================================
--- wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php (revision 676)
+++ wp-testcase/test-ajax-actions/test_admin_ajax_dim_comments.php (working copy)
@@ -188,9 +188,14 @@
$_POST['_page'] = 1;
$_POST['_url'] = admin_url( 'edit-comments.php' );
- // Make the request
- $this->setExpectedException( 'WPAjaxDieException', (string) time() );
- $this->_handleAjax( 'dim-comment' );
+ // Make the request, look for a timestamp in the exception
+ try {
+ $this->_handleAjax( 'dim-comment' );
+ $this->fail( 'Expected exception' );
+ } catch ( WPAjaxDieException $e ) {
+ $this->assertEquals( 10, strlen( $e->getMessage() ) );
+ $this->assertInternalType( 'integer', $e->getMessage() );
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment