WordPress.org

Make WordPress Core

Changeset 973 in tests


Ignore:
Timestamp:
08/16/12 17:36:20 (2 years ago)
Author:
scribu
Message:

add test_user_metadata_not_exists(). props bananastalktome. fixes #115

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/meta.php

    r904 r973  
    8484    } 
    8585 
     86    /** 
     87     * @ticket 18158 
     88     */ 
     89    function test_user_metadata_not_exists() { 
     90        $u = get_users( array( 'meta_query' => array( array( 'key' => 'meta_key', 'compare' => 'NOT EXISTS' ) ) ) ); 
     91 
     92        $this->assertEquals( 1, count( $u ) ); 
     93 
     94        // User found is not locally defined author (it's the admin) 
     95        $this->assertNotEquals( $this->author->user_login, $u[0]->user_login ); 
     96 
     97        // Test EXISTS and NOT EXISTS together, no users should be found 
     98        $this->assertEquals( 0, count( get_users( array( 'meta_query' => array( array( 'key' => 'meta_key', 'compare' => 'NOT EXISTS' ), 
     99            array( 'key' => 'delete_meta_key', 'compare' => 'EXISTS' ) ) ) ) ) ); 
     100 
     101        $this->assertEquals( 2, count( get_users( array( 'meta_query' => array( array( 'key' => 'non_existing_meta', 'compare' => 'NOT EXISTS' ) ) ) ) ) ); 
     102 
     103        delete_metadata( 'user', $this->author->ID, 'meta_key' ); 
     104        $this->assertEquals( 2, count( get_users( array( 'meta_query' => array( array( 'key' => 'meta_key', 'compare' => 'NOT EXISTS' ) ) ) ) ) ); 
     105    } 
     106 
    86107    function test_metadata_slashes() { 
    87108        $key = rand_str(); 
Note: See TracChangeset for help on using the changeset viewer.