Skip to:
Content

BuddyPress.org

Ticket #6244: 6244.unittest.patch

File 6244.unittest.patch, 2.1 KB (added by imath, 11 years ago)
  • tests/phpunit/testcases/admin/functions.php

    diff --git tests/phpunit/testcases/admin/functions.php tests/phpunit/testcases/admin/functions.php
    index eee2887..b33ccb5 100644
    class BP_Tests_Admin_Functions extends BP_UnitTestCase { 
    3838                $this->assertEquals( bp_admin_list_table_current_bulk_action(), 'foo' );
    3939        }
    4040
     41        /**
     42         * @group bp_core_admin_get_active_components_from_submitted_settings
     43         */
    4144        public function test_bp_core_admin_get_active_components_from_submitted_settings() {
    4245                $get_action = isset( $_GET['action'] ) ? $_GET['action'] : null;
    4346                $ac = buddypress()->active_components;
    class BP_Tests_Admin_Functions extends BP_UnitTestCase { 
    122125        }
    123126
    124127        /**
     128         * @group BP6244
     129         * @group bp_core_admin_get_active_components_from_submitted_settings
     130         */
     131        public function test_bp_core_admin_get_active_components_from_submitted_settings_should_keep_custom_component_directory_page() {
     132                $bp = buddypress();
     133                $reset_active_components = $bp->active_components;
     134
     135                // Create and activate the foo component
     136                $bp->foo = new BP_Component;
     137                $bp->foo->id   = 'foo';
     138                $bp->foo->slug = 'foo';
     139                $bp->foo->name = 'Foo';
     140                $bp->active_components[ $bp->foo->id ] = 1;
     141                $new_page_ids = array( $bp->foo->id => $this->factory->post->create( array(
     142                        'post_type'  => 'page',
     143                        'post_title' => $bp->foo->name,
     144                        'post_name'  => $bp->foo->slug,
     145                ) ) );
     146
     147                $page_ids = array_merge( $new_page_ids, (array) bp_core_get_directory_page_ids() );
     148                bp_core_update_directory_page_ids( $page_ids );
     149
     150                $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $reset_active_components );
     151                bp_core_add_page_mappings( $bp->active_components );
     152
     153                $this->assertContains( $bp->foo->id, array_keys( bp_core_get_directory_page_ids() ) );
     154
     155                // Reset buddypress() vars
     156                $bp->active_components = $reset_active_components;
     157        }
     158
     159        /**
    125160         * @group bp_core_activation_notice
    126161         */
    127162        public function test_bp_core_activation_notice_register_activate_pages_notcreated_signup_allowed() {