Changeset 53821 for trunk/tests/phpunit/tests/cache.php
- Timestamp:
- 08/04/2022 12:09:03 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/cache.php
r53767 r53821 27 27 } 28 28 29 /** 30 * @ticket 56198 31 * 32 * @covers WP_Object_Cache::is_valid_key 33 * @dataProvider data_is_valid_key 34 */ 35 public function test_is_valid_key( $key, $valid ) { 36 if ( wp_using_ext_object_cache() ) { 37 $this->markTestSkipped( 'This test requires that an external object cache is not in use.' ); 38 } 39 40 $val = 'val'; 41 42 if ( $valid ) { 43 $this->assertTrue( $this->cache->add( $key, $val ), 'WP_Object_Cache:add() should return true for valid keys.' ); 44 $this->assertSame( $val, $this->cache->get( $key ), 'The retrieved value should match the added value.' ); 45 } else { 46 $this->setExpectedIncorrectUsage( 'WP_Object_Cache::add' ); 47 $this->assertFalse( $this->cache->add( $key, $val ), 'WP_Object_Cache:add() should return false for invalid keys.' ); 48 } 49 } 50 51 /** 52 * Data provider for test_is_valid_key(). 53 * 54 * @return array[] Test parameters { 55 * @type mixed $key Cache key value. 56 * @type bool $valid Whether the key should be considered valid. 57 * } 58 */ 59 public function data_is_valid_key() { 60 return array( 61 array( false, false ), 62 array( null, false ), 63 array( '', false ), 64 array( 0, true ), 65 array( 1, true ), 66 array( '0', true ), 67 array( 'key', true ), 68 ); 69 } 70 29 71 public function test_miss() { 30 72 $this->assertFalse( $this->cache->get( 'test_miss' ) ); … … 113 155 114 156 public function test_flush() { 115 global $_wp_using_ext_object_cache; 116 117 if ( $_wp_using_ext_object_cache ) { 157 if ( wp_using_ext_object_cache() ) { 118 158 $this->markTestSkipped( 'This test requires that an external object cache is not in use.' ); 119 159 }
Note: See TracChangeset
for help on using the changeset viewer.