Make WordPress Core


Ignore:
Timestamp:
11/28/2013 05:09:06 AM (11 years ago)
Author:
helen
Message:

Add remove_option(), remove_options(), and get_options() methods to WP_Screen, along with unit tests. props ocean90, DrewAPicture. fixes #25799.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesScreen.php

    r25002 r26456  
    176176    }
    177177
     178    /**
     179     * @ticket 25799
     180     */
     181    function test_options() {
     182        $option = rand_str();
     183        $option_args = array(
     184            'label'   => 'Option',
     185            'default' => 10,
     186            'option'  => $option
     187        );
     188
     189        $screen = get_current_screen();
     190
     191        $screen->add_option( $option, $option_args );
     192        $this->assertEquals( $screen->get_option( $option ), $option_args );
     193
     194        $options = $screen->get_options();
     195        $this->assertArrayHasKey( $option, $options );
     196
     197        $screen->remove_option( $option );
     198        $this->assertNull( $screen->get_option( $option ) );
     199
     200        $screen->remove_options();
     201        $this->assertEquals( $screen->get_options(), array() );
     202    }
     203
    178204    function test_in_admin() {
    179205        $screen = get_current_screen();
Note: See TracChangeset for help on using the changeset viewer.