- Timestamp:
- 10/26/2023 10:54:15 PM (11 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/wpPrimeOptionCaches.php
r57012 r57013 1 1 <?php 2 2 /** 3 * Test wp_ load_options().3 * Test wp_prime_option_caches(). 4 4 * 5 5 * @group option 6 6 * 7 * @covers ::wp_ load_options7 * @covers ::wp_prime_option_caches 8 8 */ 9 class Tests_Option_ PrimeOptions extends WP_UnitTestCase {9 class Tests_Option_WpPrimeOptionCaches extends WP_UnitTestCase { 10 10 11 11 /** 12 * Tests that wp_ load_options() loads multiple options.12 * Tests that wp_prime_option_caches() primes multiple options. 13 13 * 14 14 * @ticket 58962 15 15 */ 16 public function test_wp_ load_options() {17 // Create some options to load.18 $options_to_ load= array(16 public function test_wp_prime_option_caches() { 17 // Create some options to prime. 18 $options_to_prime = array( 19 19 'option1', 20 20 'option2', … … 27 27 * check options are not in cache initially. 28 28 */ 29 foreach ( $options_to_ loadas $option ) {29 foreach ( $options_to_prime as $option ) { 30 30 update_option( $option, "value_$option", false ); 31 31 wp_cache_delete( $option, 'options' ); … … 33 33 } 34 34 35 // Call the wp_ load_options function to loadthe options.36 wp_ load_options( $options_to_load);35 // Call the wp_prime_option_caches function to prime the options. 36 wp_prime_option_caches( $options_to_prime ); 37 37 38 38 // Store the initial database query count. … … 40 40 41 41 // Check that options are only in the 'options' cache group. 42 foreach ( $options_to_ loadas $option ) {42 foreach ( $options_to_prime as $option ) { 43 43 $this->assertSame( 44 44 wp_cache_get( $option, 'options' ), 45 45 get_option( $option ), 46 "$option was not loaded tothe 'options' cache group."46 "$option was not primed in the 'options' cache group." 47 47 ); 48 48 … … 50 50 wp_cache_get( $option, 'notoptions' ), 51 51 get_option( $option ), 52 "$option was loaded tothe 'notoptions' cache group."52 "$option was primed in the 'notoptions' cache group." 53 53 ); 54 54 } … … 63 63 64 64 /** 65 * Tests wp_ load_options() with options that do not exist in the database.65 * Tests wp_prime_option_caches() with options that do not exist in the database. 66 66 * 67 67 * @ticket 58962 68 68 */ 69 public function test_wp_ load_options_with_nonexistent_options() {70 // Create some options to load.71 $options_to_ load= array(69 public function test_wp_prime_option_caches_with_nonexistent_options() { 70 // Create some options to prime. 71 $options_to_prime = array( 72 72 'option1', 73 73 'option2', … … 79 79 * check options are not in cache initially. 80 80 */ 81 foreach ( $options_to_ loadas $option ) {81 foreach ( $options_to_prime as $option ) { 82 82 $this->assertFalse( wp_cache_get( $option, 'options' ), "$option was not deleted from the cache." ); 83 83 } 84 84 85 // Call the wp_ load_options function to loadthe options.86 wp_ load_options( $options_to_load);85 // Call the wp_prime_option_caches function to prime the options. 86 wp_prime_option_caches( $options_to_prime ); 87 87 88 88 // Check that options are not in the cache or database. 89 foreach ( $options_to_ loadas $option ) {89 foreach ( $options_to_prime as $option ) { 90 90 $this->assertFalse( wp_cache_get( $option, 'options' ), "$option was not deleted from the cache." ); 91 91 } … … 94 94 $new_notoptions = wp_cache_get( 'notoptions', 'options' ); 95 95 $this->assertIsArray( $new_notoptions, 'The notoptions cache should be an array.' ); 96 foreach ( $options_to_ loadas $option ) {96 foreach ( $options_to_prime as $option ) { 97 97 $this->assertArrayHasKey( $option, $new_notoptions, "$option was not added to the notoptions cache." ); 98 98 } … … 100 100 101 101 /** 102 * Tests wp_ load_options() with an empty array.102 * Tests wp_prime_option_caches() with an empty array. 103 103 * 104 104 * @ticket 58962 105 105 */ 106 public function test_wp_ load_options_with_empty_array() {106 public function test_wp_prime_option_caches_with_empty_array() { 107 107 $alloptions = wp_load_alloptions(); 108 108 $notoptions = wp_cache_get( 'notoptions', 'options' ); 109 109 110 wp_ load_options( array() );110 wp_prime_option_caches( array() ); 111 111 112 112 $this->assertSame( $alloptions, wp_cache_get( 'alloptions', 'options' ), 'The alloptions cache was modified.' ); … … 115 115 116 116 /** 117 * Tests that wp_ load_optionshandles an empty "notoptions" cache.117 * Tests that wp_prime_option_caches() handles an empty "notoptions" cache. 118 118 * 119 119 * @ticket 58962 120 120 */ 121 public function test_wp_ load_options_handles_empty_notoptions_cache() {121 public function test_wp_prime_option_caches_handles_empty_notoptions_cache() { 122 122 wp_cache_delete( 'notoptions', 'options' ); 123 123 124 wp_ load_options( array( 'nonexistent_option' ) );124 wp_prime_option_caches( array( 'nonexistent_option' ) ); 125 125 126 126 $notoptions = wp_cache_get( 'notoptions', 'options' );
Note: See TracChangeset
for help on using the changeset viewer.