Skip to:
Content

BuddyPress.org

Changeset 9219


Ignore:
Timestamp:
12/09/2014 09:07:37 PM (10 years ago)
Author:
boonebgorges
Message:

Add tests for bp_blog_signup_enabled().

See #6045.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/template.php

    r8958 r9219  
    116116        $blogs_template->blog = null;
    117117    }
     118
     119    /**
     120     * @group bp_blog_signup_enabled
     121     */
     122    public function test_bp_signup_enabled_when_registration_setting_does_not_exist_should_default_to_true() {
     123        $old_settings = $settings = buddypress()->site_options['registration'];
     124        if ( isset( $settings['registration'] ) ) {
     125            unset( $settings['registration'] );
     126        }
     127        buddypress()->site_options = $settings;
     128
     129        $this->assertTrue( bp_blog_signup_enabled() );
     130
     131        buddypress()->site_options = $old_settings;
     132    }
     133
     134    /**
     135     * @group bp_blog_signup_enabled
     136     */
     137    public function test_bp_signup_enabled_when_registration_setting_is_all_should_return_true() {
     138        $old_settings = $settings = buddypress()->site_options['registration'];
     139
     140        if ( ! is_array( $settings ) ) {
     141            $settings = array();
     142        }
     143
     144        $settings['registration'] = 'all';
     145        buddypress()->site_options = $settings;
     146
     147        $this->assertTrue( bp_blog_signup_enabled() );
     148
     149        buddypress()->site_options = $old_settings;
     150    }
     151
     152    /**
     153     * @group bp_blog_signup_enabled
     154     */
     155    public function test_bp_signup_enabled_when_registration_setting_is_blog_should_return_true() {
     156        $old_settings = $settings = buddypress()->site_options['registration'];
     157
     158        if ( ! is_array( $settings ) ) {
     159            $settings = array();
     160        }
     161
     162        $settings['registration'] = 'blog';
     163        buddypress()->site_options = $settings;
     164
     165        $this->assertTrue( bp_blog_signup_enabled() );
     166
     167        buddypress()->site_options = $old_settings;
     168    }
     169
     170    /**
     171     * @group bp_blog_signup_enabled
     172     */
     173    public function test_bp_signup_enabled_when_registration_setting_is_user_should_return_false() {
     174        $old_settings = $settings = buddypress()->site_options['registration'];
     175
     176        if ( ! is_array( $settings ) ) {
     177            $settings = array();
     178        }
     179
     180        $settings['registration'] = 'user';
     181        buddypress()->site_options = $settings;
     182
     183        $this->assertFalse( bp_blog_signup_enabled() );
     184
     185        buddypress()->site_options = $old_settings;
     186    }
     187
     188    /**
     189     * @group bp_blog_signup_enabled
     190     */
     191    public function test_bp_signup_enabled_when_registration_setting_is_none_should_return_false() {
     192        $old_settings = $settings = buddypress()->site_options['registration'];
     193
     194        if ( ! is_array( $settings ) ) {
     195            $settings = array();
     196        }
     197
     198        $settings['registration'] = 'none';
     199        buddypress()->site_options = $settings;
     200
     201        $this->assertFalse( bp_blog_signup_enabled() );
     202
     203        buddypress()->site_options = $old_settings;
     204    }
    118205}
Note: See TracChangeset for help on using the changeset viewer.