Changeset 50265
- Timestamp:
- 02/09/2021 01:22:47 PM (4 years ago)
- Location:
- trunk/tests/phpunit/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory.php
r46586 r50265 9 9 10 10 /** 11 * Generates post fixtures for use in tests. 12 * 11 13 * @var WP_UnitTest_Factory_For_Post 12 14 */ … … 14 16 15 17 /** 18 * Generates attachment fixtures for use in tests. 19 * 16 20 * @var WP_UnitTest_Factory_For_Attachment 17 21 */ … … 19 23 20 24 /** 25 * Generates comment fixtures for use in tests. 26 * 21 27 * @var WP_UnitTest_Factory_For_Comment 22 28 */ … … 24 30 25 31 /** 32 * Generates user fixtures for use in tests. 33 * 26 34 * @var WP_UnitTest_Factory_For_User 27 35 */ … … 29 37 30 38 /** 39 * Generates taxonomy term fixtures for use in tests. 40 * 31 41 * @var WP_UnitTest_Factory_For_Term 32 42 */ … … 34 44 35 45 /** 46 * Generates category fixtures for use in tests. 47 * 36 48 * @var WP_UnitTest_Factory_For_Term 37 49 */ … … 39 51 40 52 /** 53 * Generates tag fixtures for use in tests. 54 * 41 55 * @var WP_UnitTest_Factory_For_Term 42 56 */ … … 44 58 45 59 /** 60 * Generates bookmark (link) fixtures for use in tests. 61 * 46 62 * @since 4.6.0 47 63 * @var WP_UnitTest_Factory_For_Bookmark … … 50 66 51 67 /** 68 * Generates blog (site) fixtures for use in Multisite tests. 69 * 52 70 * @var WP_UnitTest_Factory_For_Blog 53 71 */ … … 55 73 56 74 /** 75 * Generates network fixtures for use in Multisite tests. 76 * 57 77 * @var WP_UnitTest_Factory_For_Network 58 78 */ -
trunk/tests/phpunit/includes/mock-mailer.php
r49184 r50265 77 77 * @since 4.4.0 78 78 * 79 * @return object|bool79 * @return MockPHPMailer|false 80 80 */ 81 81 function tests_retrieve_phpmailer_instance() { -
trunk/tests/phpunit/includes/utils.php
r49193 r50265 3 3 // Misc help functions and utilities. 4 4 5 /** 6 * Returns a string of the required length containing random characters. Note that 7 * the maximum possible string length is 32. 8 * 9 * @param int $len Optional. The required length. Default 32. 10 * @return string The string. 11 */ 5 12 function rand_str( $len = 32 ) { 6 13 return substr( md5( uniqid( rand() ) ), 0, $len ); 7 14 } 8 15 16 /** 17 * Returns a string of the required length containing random characters. 18 * 19 * @param int $len The required length. 20 * @return string The string. 21 */ 9 22 function rand_long_str( $length ) { 10 23 $chars = 'abcdefghijklmnopqrstuvwxyz'; … … 19 32 } 20 33 21 // Strip leading and trailing whitespace from each line in the string. 34 /** 35 * Strips leading and trailing whitespace from each line in the string. 36 * 37 * @param string $txt The text. 38 * @return string Text with line-leading and line-trailing whitespace stripped. 39 */ 22 40 function strip_ws( $txt ) { 23 41 $lines = explode( "\n", $txt ); … … 34 52 /* 35 53 * Helper class for testing code that involves actions and filters. 54 * 36 55 * Typical use: 37 * $ma = new MockAction(); 38 * add_action( 'foo', array( &$ma, 'action' ) ); 56 * 57 * $ma = new MockAction(); 58 * add_action( 'foo', array( &$ma, 'action' ) ); 39 59 */ 40 60 class MockAction { … … 241 261 } 242 262 263 /** 264 * Converts an XML string into an array tree structure. 265 * 266 * The output of this function can be passed to xml_find() to find nodes by their path. 267 * 268 * @param string $in The XML string. 269 * @return array XML as an array. 270 */ 243 271 function xml_to_array( $in ) { 244 272 $p = new TestXMLParser( $in ); … … 246 274 } 247 275 276 /** 277 * Finds XML nodes by a given "path". 278 * 279 * Example usage: 280 * 281 * $tree = xml_to_array( $rss ); 282 * $items = xml_find( $tree, 'rss', 'channel', 'item' ); 283 * 284 * @param array $tree An array tree structure of XML, typically from xml_to_array(). 285 * @param string ...$elements Names of XML nodes to create a "path" to find within the XML. 286 * @return array Array of matching XML node information. 287 */ 248 288 function xml_find( $tree, ...$elements ) { 249 289 $n = count( $elements );
Note: See TracChangeset
for help on using the changeset viewer.