user->create(); $this->set_current_user( $u ); $this->go_to( bp_core_get_user_domain( $u ) ); $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => true, ) ); $this->assertEquals( '', $b->contents ); } /** * @group block_self */ public function test_block_self_others_profile() { $u1 = self::factory()->user->create(); $this->set_current_user( $u1 ); $u2 = self::factory()->user->create(); $this->go_to( bp_core_get_user_domain( $u2 ) ); $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => true, ) ); $this->assertNotEmpty( $b->contents ); } /** * @group block_self */ public function test_block_self_inside_members_loop() { $now = time(); $u1 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now ), ) ); $u2 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); $this->set_current_user( $u1 ); $found = array(); if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => true, ) ); $found[ bp_get_member_user_id() ] = empty( $b->contents ); } } $expected = array( $u1 => true, $u2 => false, ); $this->assertSame( $expected, $found ); // clean up $GLOBALS['members_template'] = null; } /** * @group block_self */ public function test_block_self_false_inside_members_loop() { $now = time(); $u1 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now ), ) ); $u2 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); $this->set_current_user( $u1 ); $found = array(); if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => false, ) ); $found[ bp_get_member_user_id() ] = empty( $b->contents ); } } $expected = array( $u1 => false, $u2 => false, ); $this->assertSame( $expected, $found ); // clean up $GLOBALS['members_template'] = null; } /** * @group block_self */ public function test_block_self_inside_members_loop_on_my_profile_page() { $now = time(); $u1 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now ), ) ); $u2 = self::factory()->user->create( array( 'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ), ) ); $this->set_current_user( $u1 ); $this->go_to( bp_core_get_user_domain( $u1 ) ); $found = array(); if ( bp_has_members() ) { while ( bp_members() ) { bp_the_member(); $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => true, ) ); $found[ bp_get_member_user_id() ] = empty( $b->contents ); } } $expected = array( $u1 => true, $u2 => false, ); $this->assertSame( $expected, $found ); // clean up $GLOBALS['members_template'] = null; } /** * @ticket BP7226 */ public function test_bp_button_new_args() { $b = new BP_Button( array( 'id' => 'foo', 'component' => 'members', 'block_self' => false, 'must_be_logged_in' => false, 'parent_element' => 'section', 'parent_attr' => array( 'class' => 'section-class', 'id' => 'section-id', 'data-parent' => 'foo', ), 'button_element' => 'button', 'button_attr' => array( 'autofocus' => 'autofocus', 'type' => 'submit', 'name' => 'my-button' ) ) ); $this->assertInternalType( 'int', strpos( $b->contents, '
assertInternalType( 'int', strpos( $b->contents, 'class="section-class ' ) ); $this->assertInternalType( 'int', strpos( $b->contents, 'id="section-id"' ) ); $this->assertInternalType( 'int', strpos( $b->contents, 'data-parent="foo"' ) ); $this->assertInternalType( 'int', strpos( $b->contents, '