Changeset 36532 for trunk/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 02/16/2016 01:56:13 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/manager.php
r36414 r36532 426 426 $this->assertNotEmpty( $data ); 427 427 428 $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl' ), array_keys( $data ) );428 $this->assertEqualSets( array( 'theme', 'url', 'browser', 'panels', 'sections', 'nonce', 'autofocus', 'documentTitleTmpl', 'previewableDevices' ), array_keys( $data ) ); 429 429 $this->assertEquals( $autofocus, $data['autofocus'] ); 430 430 $this->assertArrayHasKey( 'save', $data['nonce'] ); … … 717 717 $this->assertEquals( $control_id, $result_control->id ); 718 718 } 719 720 721 /** 722 * Testing the return values both with and without filter. 723 * 724 * @ticket 31195 725 */ 726 function test_get_previewable_devices() { 727 728 // Setup the instance. 729 $manager = new WP_Customize_Manager(); 730 731 // The default devices list. 732 $default_devices = array( 733 'desktop' => array( 734 'label' => __( 'Enter desktop preview mode' ), 735 'default' => true, 736 ), 737 'tablet' => array( 738 'label' => __( 'Enter tablet preview mode' ), 739 ), 740 'mobile' => array( 741 'label' => __( 'Enter mobile preview mode' ), 742 ), 743 ); 744 745 // Control test. 746 $devices = $manager->get_previewable_devices(); 747 $this->assertSame( $default_devices, $devices ); 748 749 // Adding the filter. 750 add_filter( 'customize_previewable_devices', array( $this, 'filter_customize_previewable_devices' ) ); 751 $devices = $manager->get_previewable_devices(); 752 $this->assertSame( $this->filtered_device_list(), $devices ); 753 754 // Clean up. 755 remove_filter( 'customize_previewable_devices', array( $this, 'filter_customize_previewable_devices' ) ); 756 } 757 758 /** 759 * Helper method for test_get_previewable_devices. 760 * 761 * @return array 762 */ 763 function filtered_device_list() { 764 return array( 765 'custom-device' => array( 766 'label' => __( 'Enter custom-device preview mode' ), 767 'default' => true, 768 ), 769 ); 770 } 771 772 /** 773 * Callback for the customize_previewable_devices filter. 774 * 775 * @param array $devices The list of devices. 776 * 777 * @return array 778 */ 779 function filter_customize_previewable_devices( $devices ) { 780 return $this->filtered_device_list(); 781 } 719 782 } 720 783
Note: See TracChangeset
for help on using the changeset viewer.