Skip to:
Content

BuddyPress.org

Changeset 9990


Ignore:
Timestamp:
07/02/2015 08:01:20 PM (11 years ago)
Author:
boonebgorges
Message:

Improved unit tests for bp_core_new_nav_item().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/nav/bpCoreNewNavItem.php

    r9988 r9990  
    6161                $this->set_current_user( $old_current_user );
    6262        }
     63
     64        public function test_should_return_false_if_name_is_not_provided() {
     65                $args = array(
     66                        'slug' => 'foo',
     67                );
     68
     69                $this->assertFalse( bp_core_new_nav_item( $args ) );
     70        }
     71
     72        public function test_should_return_false_if_slug_is_not_provided() {
     73                $args = array(
     74                        'name' => 'foo',
     75                );
     76
     77                $this->assertFalse( bp_core_new_nav_item( $args ) );
     78        }
     79
     80        public function test_should_return_false_if_site_admin_only_and_current_user_cannot_bp_moderate() {
     81                // Should already be set to a 0 user.
     82                $this->assertFalse( bp_current_user_can( 'bp_moderate' ) );
     83                $args = array(
     84                        'name' => 'Foo',
     85                        'slug' => 'foo',
     86                        'site_admin_only' => true,
     87                );
     88
     89                $this->assertFalse( bp_core_new_nav_item( $args ) );
     90        }
     91
     92        public function test_css_id_should_fall_back_on_slug() {
     93                $args = array(
     94                        'name' => 'Foo',
     95                        'slug' => 'foo',
     96                );
     97                bp_core_new_nav_item( $args );
     98
     99                $this->assertSame( 'foo', buddypress()->bp_nav['foo']['css_id'] );
     100        }
     101
     102        public function test_css_id_should_be_respected() {
     103                $args = array(
     104                        'name' => 'Foo',
     105                        'slug' => 'foo',
     106                        'item_css_id' => 'bar',
     107                );
     108                bp_core_new_nav_item( $args );
     109
     110                $this->assertSame( 'bar', buddypress()->bp_nav['foo']['css_id'] );
     111        }
     112
     113        public function test_show_for_displayed_user_false_should_force_function_to_return_false_when_bp_user_has_access_is_also_false() {
     114                $args = array(
     115                        'name' => 'Foo',
     116                        'slug' => 'foo',
     117                        'show_for_displayed_user' => false,
     118                );
     119
     120                add_filter( 'bp_user_has_access', '__return_false' );
     121                $retval = bp_core_new_nav_item( $args );
     122                remove_filter( 'bp_user_has_access', '__return_false' );
     123
     124                $this->assertFalse( $retval );
     125        }
     126
    63127}
Note: See TracChangeset for help on using the changeset viewer.