Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/19/2016 05:42:41 PM (10 years ago)
Author:
boonebgorges
Message:

In BP_XProfile_Query, fix variable name typo that prevented table JOINs from shared between meta query clauses.

Introduced in [9178].

Props thomaslhotta, r-a-y.
Fixes #7202.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-query.php

    r9819 r11018  
    470470
    471471                $expected = array( $this->users[3] );
     472                $this->assertEqualSets( $expected, array_keys( $q->results ) );
     473        }
     474
     475        /**
     476         * @ticket BP7202
     477         */
     478        public function test_relation_and_with_compare_not_in() {
     479                $this->create_fields( 1 );
     480                $this->create_users( 4 );
     481
     482                xprofile_set_field_data( $this->fields[0], $this->users[0], 'boo' );
     483                xprofile_set_field_data( $this->fields[0], $this->users[3], 'far' );
     484                xprofile_set_field_data( $this->fields[0], $this->users[1], 'foo' );
     485                xprofile_set_field_data( $this->fields[0], $this->users[2], 'bar' );
     486
     487                $q = new BP_User_Query( array(
     488                        'xprofile_query' => array(
     489                                'relation' => 'AND',
     490                                array(
     491                                        'field' => $this->fields[0],
     492                                        'compare' => 'NOT IN',
     493                                        'value' => array( 'foo', 'bar' )
     494                                ),
     495                                array(
     496                                        'field' => $this->fields[0],
     497                                        'compare' => '!=',
     498                                        'value' => 'far',
     499                                ),
     500                        ),
     501                ) );
     502
     503                $expected = array( $this->users[0] );
    472504                $this->assertEqualSets( $expected, array_keys( $q->results ) );
    473505        }
     
    568600        }
    569601
     602        /**
     603         * @group BP7202
     604         */
     605        public function test_find_compatible_table_alias_should_match_negative_siblings_joined_with_relation_and() {
     606                $this->create_fields( 1 );
     607
     608                $q = new BP_XProfile_Query( array(
     609                        'relation' => 'AND',
     610                        array(
     611                                'field' => $this->fields[0],
     612                                'compare' => '!=',
     613                                'value' => 'foo',
     614                        ),
     615                        array(
     616                                'field' => $this->fields[0],
     617                                'compare' => 'NOT IN',
     618                                'value' => array( 'bar', 'baz' ),
     619                        )
     620                ) );
     621
     622                $sql = $q->get_sql( buddypress()->profile->table_name_data, 'user_id' );
     623
     624                $this->assertSame( 1, substr_count( $sql['join'], 'INNER JOIN' ) );
     625        }
     626
    570627        /** Helpers **********************************************************/
    571628
Note: See TracChangeset for help on using the changeset viewer.