Make WordPress Core

Ticket #27272: 27272_test2.diff

File 27272_test2.diff, 1.7 KB (added by gitlost, 10 years ago)

Refresh for 4.4.

  • tests/phpunit/tests/query/metaQuery.php

     
    16941694
    16951695                $this->assertEqualSets( array( 'foo_key', 'foo_key-1', 'foo_key-2' ), array_keys( $q->meta_query->get_clauses() ) );
    16961696        }
     1697
     1698        /**
     1699         * @ticket 27272
     1700         */
     1701        public function test_cast_value_numeric_big() {
     1702                $posts = $this->factory->post->create_many( 1 );
     1703
     1704                // Will trigger (depending on system) MySQL string to float type conversion on quoted numbers.
     1705                $big_int = 0x20000000000001; // 0x20 0000 0000 0001 (54 bit integer + 1, 9007199254740993).
     1706                update_post_meta( $posts[0], 'foo', $big_int - 1 );
     1707
     1708                $q = new WP_Query( array(
     1709                        'update_post_meta_cache' => false,
     1710                        'update_term_meta_cache' => false,
     1711                        'fields' => 'ids',
     1712                        'meta_query' => array(
     1713                                array(
     1714                                        'key' => 'foo',
     1715                                        'value' => $big_int,
     1716                                        'compare' => '<',
     1717                                        'type' => 'NUMERIC',
     1718                                ),
     1719                        ),
     1720                ) );
     1721               
     1722                $this->assertEquals( array( $posts[0] ), $q->posts );
     1723        }
     1724
     1725        /**
     1726         * @ticket 27272
     1727         */
     1728        public function test_cast_value_numeric_max() {
     1729                $posts = $this->factory->post->create_many( 1 );
     1730
     1731                $max_int = PHP_INT_MAX;
     1732                update_post_meta( $posts[0], 'foo', $max_int - 1 );
     1733
     1734                $q = new WP_Query( array(
     1735                        'update_post_meta_cache' => false,
     1736                        'update_term_meta_cache' => false,
     1737                        'fields' => 'ids',
     1738                        'meta_query' => array(
     1739                                array(
     1740                                        'key' => 'foo',
     1741                                        'value' => $max_int,
     1742                                        'compare' => '<',
     1743                                        'type' => 'NUMERIC',
     1744                                ),
     1745                        ),
     1746                ) );
     1747               
     1748                $this->assertEquals( array( $posts[0] ), $q->posts );
     1749        }
    16971750}