Changeset 54530 for trunk/tests/phpunit/tests/term/taxQuery.php
- Timestamp:
- 10/17/2022 11:47:41 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/taxQuery.php
r54402 r54530 336 336 /** 337 337 * @ticket 18105 338 * @covers WP_Tax_Query::get_sql 338 339 */ 339 340 public function test_get_sql_relation_and_operator_in() { … … 382 383 $this->assertSame( 3, substr_count( $sql['join'], 'JOIN' ) ); 383 384 385 // Checking number of occurrences of AND while skipping the one at the beginning. 386 $this->assertSame( 2, substr_count( substr( $sql['where'], 5 ), 'AND' ), 'SQL query does not contain expected number conditions joined by operator AND.' ); 387 388 $this->assertStringNotContainsString( 'OR', $sql['where'], 'SQL query contains conditions joined by operator OR.' ); 389 384 390 _unregister_taxonomy( 'wptests_tax' ); 385 391 } … … 387 393 /** 388 394 * @ticket 18105 395 * @covers WP_Tax_Query::get_sql 389 396 */ 390 397 public function test_get_sql_nested_relation_or_operator_in() { … … 435 442 436 443 $this->assertSame( 2, substr_count( $sql['join'], 'JOIN' ) ); 444 $this->assertSame( 2, substr_count( $sql['where'], 'OR' ), 'SQL query does not contain expected number conditions joined by operator OR.' ); 445 $this->assertStringNotContainsString( 'AND', substr( $sql['where'], 5 ), 'SQL query contains conditions joined by operator AND.' ); 437 446 438 447 _unregister_taxonomy( 'wptests_tax' ); … … 496 505 _unregister_taxonomy( 'wptests_tax' ); 497 506 } 507 508 /** 509 * @ticket 18105 510 * @covers WP_Tax_Query::get_sql 511 */ 512 public function test_get_sql_relation_unsupported() { 513 register_taxonomy( 'wptests_tax', 'post' ); 514 515 $t1 = self::factory()->term->create( 516 array( 517 'taxonomy' => 'wptests_tax', 518 ) 519 ); 520 $t2 = self::factory()->term->create( 521 array( 522 'taxonomy' => 'wptests_tax', 523 ) 524 ); 525 $t3 = self::factory()->term->create( 526 array( 527 'taxonomy' => 'wptests_tax', 528 ) 529 ); 530 531 $tq = new WP_Tax_Query( 532 array( 533 'relation' => 'UNSUPPORTED', 534 array( 535 'taxonomy' => 'wptests_tax', 536 'field' => 'term_id', 537 'terms' => $t1, 538 ), 539 array( 540 'taxonomy' => 'wptests_tax', 541 'field' => 'term_id', 542 'terms' => $t2, 543 ), 544 array( 545 'taxonomy' => 'wptests_tax', 546 'field' => 'term_id', 547 'terms' => $t3, 548 ), 549 ) 550 ); 551 552 global $wpdb; 553 $sql = $tq->get_sql( $wpdb->posts, 'ID' ); 554 555 // Checking number of occurrences of AND while skipping the one at the beginning. 556 $this->assertSame( 2, substr_count( substr( $sql['where'], 5 ), 'AND' ), 'SQL query does not contain expected number conditions joined by operator AND.' ); 557 558 $this->assertStringNotContainsString( 'UNSUPPORTED', $sql['where'], 'SQL query contains unsupported relation operator.' ); 559 $this->assertStringNotContainsString( 'OR', $sql['where'], 'SQL query contains conditions joined by operator OR.' ); 560 561 _unregister_taxonomy( 'wptests_tax' ); 562 } 498 563 }
Note: See TracChangeset
for help on using the changeset viewer.