Changeset 35242 for trunk/tests/phpunit/tests/query/metaQuery.php
- Timestamp:
- 10/17/2015 06:02:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/metaQuery.php
r35225 r35242 7 7 class Tests_Query_MetaQuery extends WP_UnitTestCase { 8 8 public function test_meta_query_no_key() { 9 $p1 = self:: $factory->post->create();10 $p2 = self:: $factory->post->create();11 $p3 = self:: $factory->post->create();9 $p1 = self::factory()->post->create(); 10 $p2 = self::factory()->post->create(); 11 $p3 = self::factory()->post->create(); 12 12 13 13 add_post_meta( $p1, 'foo', 'bar' ); … … 31 31 32 32 public function test_meta_query_no_value() { 33 $p1 = self:: $factory->post->create();34 $p2 = self:: $factory->post->create();35 $p3 = self:: $factory->post->create();33 $p1 = self::factory()->post->create(); 34 $p2 = self::factory()->post->create(); 35 $p3 = self::factory()->post->create(); 36 36 37 37 add_post_meta( $p1, 'foo', 'bar' ); … … 55 55 56 56 public function test_meta_query_single_query_compare_default() { 57 $p1 = self:: $factory->post->create();58 $p2 = self:: $factory->post->create();57 $p1 = self::factory()->post->create(); 58 $p2 = self::factory()->post->create(); 59 59 60 60 add_post_meta( $p1, 'foo', 'bar' ); … … 77 77 78 78 public function test_meta_query_single_query_compare_equals() { 79 $p1 = self:: $factory->post->create();80 $p2 = self:: $factory->post->create();79 $p1 = self::factory()->post->create(); 80 $p2 = self::factory()->post->create(); 81 81 82 82 add_post_meta( $p1, 'foo', 'bar' ); … … 100 100 101 101 public function test_meta_query_single_query_compare_not_equals() { 102 $p1 = self:: $factory->post->create();103 $p2 = self:: $factory->post->create();104 $p3 = self:: $factory->post->create();102 $p1 = self::factory()->post->create(); 103 $p2 = self::factory()->post->create(); 104 $p3 = self::factory()->post->create(); 105 105 106 106 add_post_meta( $p1, 'foo', 'bar' ); … … 125 125 126 126 public function test_meta_query_single_query_compare_arithmetic_comparisons() { 127 $p1 = self:: $factory->post->create();128 $p2 = self:: $factory->post->create();129 $p3 = self:: $factory->post->create();127 $p1 = self::factory()->post->create(); 128 $p2 = self::factory()->post->create(); 129 $p3 = self::factory()->post->create(); 130 130 131 131 add_post_meta( $p1, 'foo', '1' ); … … 203 203 204 204 public function test_meta_query_single_query_compare_like() { 205 $p1 = self:: $factory->post->create();206 $p2 = self:: $factory->post->create();205 $p1 = self::factory()->post->create(); 206 $p2 = self::factory()->post->create(); 207 207 208 208 add_post_meta( $p1, 'foo', 'bar' ); … … 226 226 227 227 public function test_meta_query_single_query_compare_not_like() { 228 $p1 = self:: $factory->post->create();229 $p2 = self:: $factory->post->create();230 $p3 = self:: $factory->post->create();228 $p1 = self::factory()->post->create(); 229 $p2 = self::factory()->post->create(); 230 $p3 = self::factory()->post->create(); 231 231 232 232 add_post_meta( $p1, 'foo', 'bar' ); … … 251 251 252 252 public function test_meta_query_single_query_compare_between_not_between() { 253 $p1 = self:: $factory->post->create();254 $p2 = self:: $factory->post->create();255 $p3 = self:: $factory->post->create();253 $p1 = self::factory()->post->create(); 254 $p2 = self::factory()->post->create(); 255 $p3 = self::factory()->post->create(); 256 256 257 257 add_post_meta( $p1, 'foo', '1' ); … … 295 295 296 296 public function test_meta_query_single_query_compare_regexp_rlike() { 297 $p1 = self:: $factory->post->create();298 $p2 = self:: $factory->post->create();297 $p1 = self::factory()->post->create(); 298 $p2 = self::factory()->post->create(); 299 299 300 300 add_post_meta( $p1, 'foo', 'bar' ); … … 336 336 337 337 public function test_meta_query_single_query_compare_not_regexp() { 338 $p1 = self:: $factory->post->create();339 $p2 = self:: $factory->post->create();338 $p1 = self::factory()->post->create(); 339 $p2 = self::factory()->post->create(); 340 340 341 341 add_post_meta( $p1, 'foo', 'bar' ); … … 360 360 361 361 public function test_meta_query_relation_default() { 362 $p1 = self:: $factory->post->create();363 $p2 = self:: $factory->post->create();364 $p3 = self:: $factory->post->create();362 $p1 = self::factory()->post->create(); 363 $p2 = self::factory()->post->create(); 364 $p3 = self::factory()->post->create(); 365 365 366 366 add_post_meta( $p1, 'foo', 'foo value 1' ); … … 390 390 391 391 public function test_meta_query_relation_or() { 392 $post_id = self:: $factory->post->create();392 $post_id = self::factory()->post->create(); 393 393 add_post_meta( $post_id, 'foo', rand_str() ); 394 394 add_post_meta( $post_id, 'foo', rand_str() ); 395 $post_id2 = self:: $factory->post->create();395 $post_id2 = self::factory()->post->create(); 396 396 add_post_meta( $post_id2, 'bar', 'val2' ); 397 $post_id3 = self:: $factory->post->create();397 $post_id3 = self::factory()->post->create(); 398 398 add_post_meta( $post_id3, 'baz', rand_str() ); 399 $post_id4 = self:: $factory->post->create();399 $post_id4 = self::factory()->post->create(); 400 400 add_post_meta( $post_id4, 'froo', rand_str() ); 401 $post_id5 = self:: $factory->post->create();401 $post_id5 = self::factory()->post->create(); 402 402 add_post_meta( $post_id5, 'tango', 'val2' ); 403 $post_id6 = self:: $factory->post->create();403 $post_id6 = self::factory()->post->create(); 404 404 add_post_meta( $post_id6, 'bar', 'val1' ); 405 405 … … 431 431 432 432 public function test_meta_query_relation_and() { 433 $post_id = self:: $factory->post->create();433 $post_id = self::factory()->post->create(); 434 434 add_post_meta( $post_id, 'foo', rand_str() ); 435 435 add_post_meta( $post_id, 'foo', rand_str() ); 436 $post_id2 = self:: $factory->post->create();436 $post_id2 = self::factory()->post->create(); 437 437 add_post_meta( $post_id2, 'bar', 'val2' ); 438 438 add_post_meta( $post_id2, 'foo', rand_str() ); 439 $post_id3 = self:: $factory->post->create();439 $post_id3 = self::factory()->post->create(); 440 440 add_post_meta( $post_id3, 'baz', rand_str() ); 441 $post_id4 = self:: $factory->post->create();441 $post_id4 = self::factory()->post->create(); 442 442 add_post_meta( $post_id4, 'froo', rand_str() ); 443 $post_id5 = self:: $factory->post->create();443 $post_id5 = self::factory()->post->create(); 444 444 add_post_meta( $post_id5, 'tango', 'val2' ); 445 $post_id6 = self:: $factory->post->create();445 $post_id6 = self::factory()->post->create(); 446 446 add_post_meta( $post_id6, 'bar', 'val1' ); 447 447 add_post_meta( $post_id6, 'foo', rand_str() ); 448 $post_id7 = self:: $factory->post->create();448 $post_id7 = self::factory()->post->create(); 449 449 add_post_meta( $post_id7, 'foo', rand_str() ); 450 450 add_post_meta( $post_id7, 'froo', rand_str() ); … … 500 500 */ 501 501 public function test_meta_query_compare_exists() { 502 $posts = self:: $factory->post->create_many( 3 );502 $posts = self::factory()->post->create_many( 3 ); 503 503 add_post_meta( $posts[0], 'foo', 'bar' ); 504 504 add_post_meta( $posts[2], 'foo', 'baz' ); … … 521 521 */ 522 522 public function test_meta_query_compare_exists_with_value_should_convert_to_equals() { 523 $posts = self:: $factory->post->create_many( 3 );523 $posts = self::factory()->post->create_many( 3 ); 524 524 add_post_meta( $posts[0], 'foo', 'bar' ); 525 525 add_post_meta( $posts[2], 'foo', 'baz' ); … … 543 543 */ 544 544 public function test_meta_query_compare_not_exists_should_ignore_value() { 545 $posts = self:: $factory->post->create_many( 3 );545 $posts = self::factory()->post->create_many( 3 ); 546 546 add_post_meta( $posts[0], 'foo', 'bar' ); 547 547 add_post_meta( $posts[2], 'foo', 'baz' ); … … 565 565 */ 566 566 public function test_meta_query_compare_not_exists() { 567 $post_id = self:: $factory->post->create();567 $post_id = self::factory()->post->create(); 568 568 add_post_meta( $post_id, 'foo', rand_str() ); 569 $post_id2 = self:: $factory->post->create();569 $post_id2 = self::factory()->post->create(); 570 570 add_post_meta( $post_id2, 'bar', rand_str() ); 571 $post_id3 = self:: $factory->post->create();571 $post_id3 = self::factory()->post->create(); 572 572 add_post_meta( $post_id3, 'bar', rand_str() ); 573 $post_id4 = self:: $factory->post->create();573 $post_id4 = self::factory()->post->create(); 574 574 add_post_meta( $post_id4, 'baz', rand_str() ); 575 $post_id5 = self:: $factory->post->create();575 $post_id5 = self::factory()->post->create(); 576 576 add_post_meta( $post_id5, 'foo', rand_str() ); 577 577 … … 637 637 */ 638 638 public function test_meta_query_compare_not_exists_with_another_condition_relation_or() { 639 $posts = self:: $factory->post->create_many( 4 );639 $posts = self::factory()->post->create_many( 4 ); 640 640 update_post_meta( $posts[0], 'color', 'orange' ); 641 641 update_post_meta( $posts[1], 'color', 'blue' ); … … 673 673 */ 674 674 public function test_meta_query_relation_or_compare_equals() { 675 $posts = self:: $factory->post->create_many( 4 );675 $posts = self::factory()->post->create_many( 4 ); 676 676 add_post_meta( $posts[0], 'color', 'orange' ); 677 677 add_post_meta( $posts[1], 'color', 'blue' ); … … 706 706 */ 707 707 public function test_meta_query_relation_or_compare_equals_different_keys() { 708 $posts = self:: $factory->post->create_many( 4 );708 $posts = self::factory()->post->create_many( 4 ); 709 709 add_post_meta( $posts[0], 'color', 'orange' ); 710 710 add_post_meta( $posts[1], 'color', 'blue' ); … … 739 739 */ 740 740 public function test_meta_query_relation_or_compare_equals_and_in() { 741 $posts = self:: $factory->post->create_many( 4 );741 $posts = self::factory()->post->create_many( 4 ); 742 742 add_post_meta( $posts[0], 'color', 'orange' ); 743 743 add_post_meta( $posts[1], 'color', 'blue' ); … … 772 772 */ 773 773 public function test_meta_query_relation_or_compare_equals_and_like() { 774 $posts = self:: $factory->post->create_many( 4 );774 $posts = self::factory()->post->create_many( 4 ); 775 775 add_post_meta( $posts[0], 'color', 'orange' ); 776 776 add_post_meta( $posts[1], 'color', 'blue' ); … … 805 805 */ 806 806 public function test_meta_query_relation_or_compare_equals_and_between() { 807 $posts = self:: $factory->post->create_many( 4 );807 $posts = self::factory()->post->create_many( 4 ); 808 808 add_post_meta( $posts[0], 'number_of_colors', '2' ); 809 809 add_post_meta( $posts[1], 'number_of_colors', '5' ); … … 839 839 */ 840 840 public function test_meta_query_relation_and_compare_in_same_keys() { 841 $posts = self:: $factory->post->create_many( 4 );841 $posts = self::factory()->post->create_many( 4 ); 842 842 add_post_meta( $posts[0], 'color', 'orange' ); 843 843 add_post_meta( $posts[1], 'color', 'blue' ); … … 874 874 */ 875 875 public function test_meta_query_relation_and_compare_in_different_keys() { 876 $posts = self:: $factory->post->create_many( 4 );876 $posts = self::factory()->post->create_many( 4 ); 877 877 add_post_meta( $posts[0], 'color', 'orange' ); 878 878 add_post_meta( $posts[1], 'color', 'blue' ); … … 909 909 */ 910 910 public function test_meta_query_relation_and_compare_not_equals() { 911 $posts = self:: $factory->post->create_many( 4 );911 $posts = self::factory()->post->create_many( 4 ); 912 912 add_post_meta( $posts[0], 'color', 'orange' ); 913 913 add_post_meta( $posts[1], 'color', 'blue' ); … … 943 943 */ 944 944 public function test_meta_query_relation_and_compare_not_equals_different_keys() { 945 $posts = self:: $factory->post->create_many( 4 );945 $posts = self::factory()->post->create_many( 4 ); 946 946 947 947 // !shallot, but orange. … … 984 984 */ 985 985 public function test_meta_query_relation_and_compare_not_equals_not_in() { 986 $posts = self:: $factory->post->create_many( 4 );986 $posts = self::factory()->post->create_many( 4 ); 987 987 add_post_meta( $posts[0], 'color', 'orange' ); 988 988 add_post_meta( $posts[1], 'color', 'blue' ); … … 1018 1018 */ 1019 1019 public function test_meta_query_relation_and_compare_not_equals_and_not_like() { 1020 $posts = self:: $factory->post->create_many( 4 );1020 $posts = self::factory()->post->create_many( 4 ); 1021 1021 add_post_meta( $posts[0], 'color', 'orange' ); 1022 1022 add_post_meta( $posts[1], 'color', 'blue' ); … … 1052 1052 */ 1053 1053 public function test_meta_query_decimal_results() { 1054 $post_1 = self:: $factory->post->create();1055 $post_2 = self:: $factory->post->create();1056 $post_3 = self:: $factory->post->create();1057 $post_4 = self:: $factory->post->create();1054 $post_1 = self::factory()->post->create(); 1055 $post_2 = self::factory()->post->create(); 1056 $post_3 = self::factory()->post->create(); 1057 $post_4 = self::factory()->post->create(); 1058 1058 1059 1059 update_post_meta( $post_1, 'decimal_value', '-0.3' ); … … 1227 1227 */ 1228 1228 public function test_meta_query_with_orderby_meta_value_relation_or() { 1229 $posts = self:: $factory->post->create_many( 4 );1229 $posts = self::factory()->post->create_many( 4 ); 1230 1230 update_post_meta( $posts[0], 'foo', 5 ); 1231 1231 update_post_meta( $posts[1], 'foo', 6 ); … … 1266 1266 */ 1267 1267 public function test_meta_query_with_orderby_meta_value_relation_and() { 1268 $posts = self:: $factory->post->create_many( 4 );1268 $posts = self::factory()->post->create_many( 4 ); 1269 1269 update_post_meta( $posts[0], 'foo', 5 ); 1270 1270 update_post_meta( $posts[1], 'foo', 6 ); … … 1309 1309 */ 1310 1310 public function test_meta_query_nested() { 1311 $p1 = self:: $factory->post->create();1312 $p2 = self:: $factory->post->create();1313 $p3 = self:: $factory->post->create();1311 $p1 = self::factory()->post->create(); 1312 $p2 = self::factory()->post->create(); 1313 $p3 = self::factory()->post->create(); 1314 1314 1315 1315 add_post_meta( $p1, 'foo', 'bar' ); … … 1350 1350 */ 1351 1351 public function test_meta_query_nested_two_levels_deep() { 1352 $p1 = self:: $factory->post->create();1353 $p2 = self:: $factory->post->create();1354 $p3 = self:: $factory->post->create();1352 $p1 = self::factory()->post->create(); 1353 $p2 = self::factory()->post->create(); 1354 $p3 = self::factory()->post->create(); 1355 1355 1356 1356 add_post_meta( $p1, 'foo', 'bar' ); … … 1395 1395 1396 1396 public function test_meta_between_not_between() { 1397 $post_id = self:: $factory->post->create();1397 $post_id = self::factory()->post->create(); 1398 1398 add_post_meta( $post_id, 'time', 500 ); 1399 $post_id2 = self:: $factory->post->create();1399 $post_id2 = self::factory()->post->create(); 1400 1400 add_post_meta( $post_id2, 'time', 1001 ); 1401 $post_id3 = self:: $factory->post->create();1401 $post_id3 = self::factory()->post->create(); 1402 1402 add_post_meta( $post_id3, 'time', 0 ); 1403 $post_id4 = self:: $factory->post->create();1403 $post_id4 = self::factory()->post->create(); 1404 1404 add_post_meta( $post_id4, 'time', 1 ); 1405 $post_id5 = self:: $factory->post->create();1405 $post_id5 = self::factory()->post->create(); 1406 1406 add_post_meta( $post_id5, 'time', 1000 ); 1407 1407 … … 1444 1444 public function test_meta_default_compare() { 1445 1445 // compare should default to IN when meta_value is an array 1446 $post_id = self:: $factory->post->create();1446 $post_id = self::factory()->post->create(); 1447 1447 add_post_meta( $post_id, 'foo', 'bar' ); 1448 $post_id2 = self:: $factory->post->create();1448 $post_id2 = self::factory()->post->create(); 1449 1449 add_post_meta( $post_id2, 'bar', 'baz' ); 1450 $post_id3 = self:: $factory->post->create();1450 $post_id3 = self::factory()->post->create(); 1451 1451 add_post_meta( $post_id3, 'foo', 'baz' ); 1452 $post_id4 = self:: $factory->post->create();1452 $post_id4 = self::factory()->post->create(); 1453 1453 add_post_meta( $post_id4, 'baz', 'bar' ); 1454 $post_id5 = self:: $factory->post->create();1454 $post_id5 = self::factory()->post->create(); 1455 1455 add_post_meta( $post_id5, 'foo', rand_str() ); 1456 1456 … … 1483 1483 */ 1484 1484 public function test_duplicate_posts_when_no_key() { 1485 $post_id = self:: $factory->post->create();1485 $post_id = self::factory()->post->create(); 1486 1486 add_post_meta( $post_id, 'city', 'Lorem' ); 1487 1487 add_post_meta( $post_id, 'address', '123 Lorem St.' ); 1488 $post_id2 = self:: $factory->post->create();1488 $post_id2 = self::factory()->post->create(); 1489 1489 add_post_meta( $post_id2, 'city', 'Lorem' ); 1490 $post_id3 = self:: $factory->post->create();1490 $post_id3 = self::factory()->post->create(); 1491 1491 add_post_meta( $post_id3, 'city', 'Loren' ); 1492 1492 … … 1514 1514 */ 1515 1515 public function test_empty_meta_value() { 1516 $post_id = self:: $factory->post->create();1516 $post_id = self::factory()->post->create(); 1517 1517 add_post_meta( $post_id, 'foo', '0' ); 1518 1518 add_post_meta( $post_id, 'bar', 0 ); 1519 $post_id2 = self:: $factory->post->create();1519 $post_id2 = self::factory()->post->create(); 1520 1520 add_post_meta( $post_id2, 'foo', 1 ); 1521 $post_id3 = self:: $factory->post->create();1521 $post_id3 = self::factory()->post->create(); 1522 1522 add_post_meta( $post_id3, 'baz', 0 ); 1523 $post_id4 = self:: $factory->post->create();1523 $post_id4 = self::factory()->post->create(); 1524 1524 add_post_meta( $post_id4, 'baz', 0 ); 1525 $post_id5 = self:: $factory->post->create();1525 $post_id5 = self::factory()->post->create(); 1526 1526 add_post_meta( $post_id5, 'baz', 0 ); 1527 1527 add_post_meta( $post_id5, 'bar', '0' ); 1528 $post_id6 = self:: $factory->post->create();1528 $post_id6 = self::factory()->post->create(); 1529 1529 add_post_meta( $post_id6, 'baz', 0 ); 1530 1530 … … 1578 1578 */ 1579 1579 public function test_orderby_clause_key() { 1580 $posts = self:: $factory->post->create_many( 3 );1580 $posts = self::factory()->post->create_many( 3 ); 1581 1581 add_post_meta( $posts[0], 'foo', 'aaa' ); 1582 1582 add_post_meta( $posts[1], 'foo', 'zzz' ); … … 1602 1602 */ 1603 1603 public function test_orderby_clause_key_as_secondary_sort() { 1604 $p1 = self:: $factory->post->create( array(1604 $p1 = self::factory()->post->create( array( 1605 1605 'post_date' => '2015-01-28 03:00:00', 1606 1606 ) ); 1607 $p2 = self:: $factory->post->create( array(1607 $p2 = self::factory()->post->create( array( 1608 1608 'post_date' => '2015-01-28 05:00:00', 1609 1609 ) ); 1610 $p3 = self:: $factory->post->create( array(1610 $p3 = self::factory()->post->create( array( 1611 1611 'post_date' => '2015-01-28 03:00:00', 1612 1612 ) ); … … 1637 1637 */ 1638 1638 public function test_orderby_more_than_one_clause_key() { 1639 $posts = self:: $factory->post->create_many( 3 );1639 $posts = self::factory()->post->create_many( 3 ); 1640 1640 1641 1641 add_post_meta( $posts[0], 'foo', 'jjj' );
Note: See TracChangeset
for help on using the changeset viewer.