Skip to:
Content

BuddyPress.org

Changeset 8153


Ignore:
Timestamp:
03/25/2014 12:28:36 AM (12 years ago)
Author:
boonebgorges
Message:

Add test for sort_order and order_by date in notifications component.

See #5452

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/notifications/class-bp-notifications-notification.php

    r7694 r8153  
    117117        }
    118118
     119        /**
     120         * @group order_by
     121         * @group sort_order
     122         */
     123        public function test_order_by_date() {
     124                $now = time();
     125                $u = $this->create_user();
     126                $n1 = $this->factory->notification->create( array(
     127                        'component_name' => 'friends',
     128                        'user_id' => $u,
     129                        'date_notified' => date( 'Y-m-d H:i:s', $now - 500 ),
     130                ) );
     131                $n2 = $this->factory->notification->create( array(
     132                        'component_name' => 'groups',
     133                        'user_id' => $u,
     134                        'date_notified' => date( 'Y-m-d H:i:s', $now - 100 ),
     135                ) );
     136                $n3 = $this->factory->notification->create( array(
     137                        'component_name' => 'messages',
     138                        'user_id' => $u,
     139                        'date_notified' => date( 'Y-m-d H:i:s', $now - 1000 ),
     140                ) );
     141
     142                $n = BP_Notifications_Notification::get( array(
     143                        'user_id' => $u,
     144                        'order_by' => 'date_notified',
     145                        'sort_order' => 'DESC',
     146                ) );
     147
     148                // Check that the correct items are pulled up
     149                $expected = array( $n2, $n1, $n3 );
     150                $actual = wp_list_pluck( $n, 'id' );
     151                $this->assertEquals( $expected, $actual );
     152        }
    119153}
Note: See TracChangeset for help on using the changeset viewer.