Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2016 05:43:23 PM (9 years ago)
Author:
r-a-y
Message:

Notifications: Make notification meta great again.

This commit fixes this for the betterment of notifications everywhere.

Fixes #7067.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/notifications/functions.php

    r10437 r10788  
    122122
    123123        $this->assertFalse( wp_cache_get( 'all_for_user_' . $u, 'bp_notifications' ) );
     124    }
     125
     126    /**
     127     * @group bp_notifications_update_meta_cache
     128     */
     129    public function test_bp_notifications_update_meta_cache() {
     130        $u = $this->factory->user->create();
     131
     132        $n1 = $this->factory->notification->create( array(
     133            'component_name' => 'messages',
     134            'user_id'        => $u
     135        ) );
     136
     137        $n2 = $this->factory->notification->create( array(
     138            'component_name' => 'groups',
     139            'user_id'        => $u
     140        ) );
     141
     142        // Add cache for each notification.
     143        bp_notifications_update_meta( $n1, 'meta', 'data' );
     144        bp_notifications_update_meta( $n1, 'data', 'meta' );
     145        bp_notifications_update_meta( $n2, 'meta', 'human' );
     146
     147        // Prime cache.
     148        bp_notifications_get_meta( $n1, 'meta' );
     149
     150        // Ensure an empty cache for second notification.
     151        wp_cache_delete( $n2, 'notification_meta' );
     152
     153        // Update notification meta cache.
     154        bp_notifications_update_meta_cache( array( $n1, $n2 ) );
     155
     156        $expected = array(
     157            $n1 => array(
     158                'meta' => array(
     159                    'data',
     160                ),
     161                'data' => array(
     162                    'meta',
     163                ),
     164            ),
     165            $n2 => array(
     166                'meta' => array(
     167                    'human',
     168                ),
     169            ),
     170        );
     171
     172        $found = array(
     173            $n1 => wp_cache_get( $n1, 'notification_meta' ),
     174            $n2 => wp_cache_get( $n2, 'notification_meta' ),
     175        );
     176
     177        $this->assertEquals( $expected, $found );
    124178    }
    125179
Note: See TracChangeset for help on using the changeset viewer.