Changeset 47122 for trunk/tests/phpunit/tests/ajax/TagSearch.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/TagSearch.php
r46586 r47122 2 2 3 3 /** 4 * Admin ajax functions to be tested4 * Admin Ajax functions to be tested. 5 5 */ 6 6 require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' ); 7 7 8 8 /** 9 * Testing ajax tag search functionality9 * Testing Ajax tag search functionality. 10 10 * 11 11 * @package WordPress … … 43 43 public function test_post_tag() { 44 44 45 // Become an administrator 45 // Become an administrator. 46 46 $this->_setRole( 'administrator' ); 47 47 48 // Set up a default request 48 // Set up a default request. 49 49 $_GET['tax'] = 'post_tag'; 50 50 $_GET['q'] = 'chat'; 51 51 52 // Make the request 52 // Make the request. 53 53 try { 54 54 $this->_handleAjax( 'ajax-tag-search' ); … … 57 57 } 58 58 59 // Ensure we found the right match 59 // Ensure we found the right match. 60 60 $this->assertEquals( $this->_last_response, 'chattels' ); 61 61 } … … 66 66 public function test_no_results() { 67 67 68 // Become an administrator 68 // Become an administrator. 69 69 $this->_setRole( 'administrator' ); 70 70 71 // Set up a default request 71 // Set up a default request. 72 72 $_GET['tax'] = 'post_tag'; 73 73 $_GET['q'] = md5( uniqid() ); 74 74 75 // Make the request 76 // No output, so we get a stop exception 75 // Make the request. 76 // No output, so we get a stop exception. 77 77 $this->setExpectedException( 'WPAjaxDieStopException', '' ); 78 78 $this->_handleAjax( 'ajax-tag-search' ); … … 84 84 public function test_with_comma() { 85 85 86 // Become an administrator 86 // Become an administrator. 87 87 $this->_setRole( 'administrator' ); 88 88 89 // Set up a default request 89 // Set up a default request. 90 90 $_GET['tax'] = 'post_tag'; 91 $_GET['q'] = 'some,nonsense, terms,chat'; // Only the last term in the list is searched 91 $_GET['q'] = 'some,nonsense, terms,chat'; // Only the last term in the list is searched. 92 92 93 // Make the request 93 // Make the request. 94 94 try { 95 95 $this->_handleAjax( 'ajax-tag-search' ); … … 98 98 } 99 99 100 // Ensure we found the right match 100 // Ensure we found the right match. 101 101 $this->assertEquals( $this->_last_response, 'chattels' ); 102 102 } … … 107 107 public function test_logged_out() { 108 108 109 // Log out 109 // Log out. 110 110 wp_logout(); 111 111 112 // Set up a default request 112 // Set up a default request. 113 113 $_GET['tax'] = 'post_tag'; 114 114 $_GET['q'] = 'chat'; 115 115 116 // Make the request 116 // Make the request. 117 117 $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); 118 118 $this->_handleAjax( 'ajax-tag-search' ); … … 124 124 public function test_invalid_tax() { 125 125 126 // Become an administrator 126 // Become an administrator. 127 127 $this->_setRole( 'administrator' ); 128 128 129 // Set up a default request 129 // Set up a default request. 130 130 $_GET['tax'] = 'invalid-taxonomy'; 131 131 $_GET['q'] = 'chat'; 132 132 133 // Make the request 133 // Make the request. 134 134 $this->setExpectedException( 'WPAjaxDieStopException', '0' ); 135 135 $this->_handleAjax( 'ajax-tag-search' ); … … 141 141 public function test_unprivileged_user() { 142 142 143 // Become a n administrator143 // Become a subscriber. 144 144 $this->_setRole( 'subscriber' ); 145 145 146 // Set up a default request 146 // Set up a default request. 147 147 $_GET['tax'] = 'post_tag'; 148 148 $_GET['q'] = 'chat'; 149 149 150 // Make the request 150 // Make the request. 151 151 $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); 152 152 $this->_handleAjax( 'ajax-tag-search' );
Note: See TracChangeset
for help on using the changeset viewer.