public function testMapDate() { update_option('fields', array('post_date' => 1)); register_post_type('post'); wp_insert_post(array('post_type' => 'post', 'post_date' => '07/30/1989 00:00:00 CST')); wp_insert_post(array('post_type' => 'post', 'post_date' => '10/30/1988 00:00:00 CST')); Indexer::_map(); Indexer::reindex(); $this->index->refresh(); $search = new \Elastica\Search($this->index->getClient()); $search->addIndex($this->index); $results = $search->search(new \Elastica\Query(array('sort' => array('post_date' => array('order' => 'asc')))))->getResults(); $this->assertCount(2, $results); $this->assertEquals(2, $results[0]->getId()); $this->assertEquals(1, $results[1]->getId()); $results = $search->search(new \Elastica\Query(array('sort' => array('post_date' => array('order' => 'desc')))))->getResults(); $this->assertCount(2, $results); $this->assertEquals(1, $results[0]->getId()); $this->assertEquals(2, $results[1]->getId()); }