[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/testcases/activity/functions/ -> bpActivityGetActionsForContext.php (source)

   1  <?php
   2  
   3  /**
   4   * @group activity
   5   */
   6  class BP_Tests_Activity_Functions_BpActivityGetActionsForContext extends BP_UnitTestCase {
   7  	public function setUp() {
   8          parent::setUp();
   9  
  10          $bp = buddypress();
  11  
  12          $this->reset_actions = clone $bp->activity->actions;
  13          $bp->activity->actions = new stdClass();
  14  
  15          $this->reset_actions_sorted = ! empty( $bp->activity->actions_sorted );
  16          unset( $bp->activity->actions_sorted );
  17      }
  18  
  19  	public function tearDown() {
  20          $bp = buddypress();
  21  
  22          $bp->activity->actions = $this->reset_actions;
  23  
  24          if ( $this->reset_actions_sorted ) {
  25              $bp->activity->actions_sorted = true;
  26          } else {
  27              unset( $bp->activity->actions_sorted );
  28          }
  29  
  30          parent::tearDown();
  31      }
  32  
  33      public function test_should_include_actions_registered_for_context() {
  34          bp_activity_set_action(
  35              'foo',
  36              'new_foo',
  37              'Did a foo',
  38              '',
  39              '',
  40              array( 'member' ),
  41              10
  42          );
  43  
  44          $actions = bp_activity_get_actions_for_context( 'member' );
  45          $keys = wp_list_pluck( $actions, 'key' );
  46          $this->assertContains( 'new_foo', $keys );
  47      }
  48  
  49      public function test_should_ignore_actions_not_registered_for_context() {
  50          bp_activity_set_action(
  51              'foo',
  52              'new_foo',
  53              'Did a foo',
  54              '',
  55              '',
  56              array( 'member' ),
  57              10
  58          );
  59  
  60          $actions = bp_activity_get_actions_for_context( 'group' );
  61          $keys = wp_list_pluck( $actions, 'key' );
  62          $this->assertNotContains( 'new_foo', $keys );
  63      }
  64  }


Generated: Tue Oct 22 01:01:36 2019 Cross-referenced by PHPXref 0.7.1