Changeset 10250
- Timestamp:
- 09/11/2020 04:41:56 PM (5 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/events/1.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r10249 r10250 40 40 // The test suite just needs the functions defined and doesn't want any headers or output 41 41 if ( defined( 'RUNNING_TESTS' ) && RUNNING_TESTS ) { 42 disable_caching(); 42 43 return; 43 44 } 44 45 45 wp_cache_init(); 46 // Disable object caching during manual testing, unless explicitly testing caching. 47 if ( is_test_request() && empty( $_GET['cache'] ) ) { 48 disable_caching(); 49 } else { 50 wp_cache_init(); 51 } 46 52 47 53 $cache_group = 'events'; … … 53 59 54 60 send_response( $response, $ttl ); 61 } 62 63 /** 64 * Determine if the current request is a developer manually testing on their sandbox. 65 * 66 * @return bool 67 */ 68 function is_test_request() { 69 $proxied = defined( 'WPORG_PROXIED_REQUEST' ) && WPORG_PROXIED_REQUEST; 70 $sandbox = defined( 'WPORG_SANDBOXED' ) && WPORG_SANDBOXED; 71 72 return $proxied && $sandbox; 73 } 74 75 /** 76 * Mock the caching functions. 77 */ 78 function disable_caching() { 79 /** 80 * Stub to simulate cache misses, so that the tests always get fresh results 81 * 82 * @return false 83 */ 84 function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { 85 return false; 86 } 87 88 /** 89 * Stub to avoid setting production object cache values while testing. 90 */ 91 function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { 92 // Intentionally empty 93 } 55 94 } 56 95 -
sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php
r9785 r10250 1530 1530 } 1531 1531 1532 /**1533 * Stub to simulate cache misses, so that the tests always get fresh results1534 *1535 * @return false1536 */1537 function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {1538 return false;1539 }1540 1541 /**1542 * Stub to simulate cache misses, so that the tests always get fresh results1543 */1544 function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {1545 // Intentionally empty1546 }1547 1548 1549 1532 define( 'VERBOSE_OUTPUT', in_array( '--verbose', $argv, true ) ); 1550 1533
Note: See TracChangeset
for help on using the changeset viewer.