コード例 #1
0
 public function testMultiGet()
 {
     $type1 = new CM_Elasticsearch_Type_Mock1();
     $type2 = new CM_Elasticsearch_Type_Mock2();
     $source = new CM_PagingSource_Elasticsearch(array($type1, $type2), new CM_Elasticsearch_Query());
     $this->assertSame(0, $source->getCount());
     $id1 = $type1->createEntry('foo');
     $this->assertSame(1, $source->getCount());
     $id2 = $type2->createEntry(1);
     $this->assertSame(2, $source->getCount());
     $this->assertContainsAll(array(array('id' => (string) $id1, 'type' => 'index_1'), array('id' => (string) $id2, 'type' => 'index_2')), $source->getItems());
     $type3 = new CM_Elasticsearch_Type_Mock3();
     $source = new CM_PagingSource_Elasticsearch(array($type1, $type2, $type3), new CM_Elasticsearch_Query(), array('price'));
     $id3 = $type3->createEntry(5);
     $this->assertSame(3, $source->getCount());
     $this->assertContainsAll(array(array('id' => (string) $id1, 'type' => 'index_1'), array('id' => (string) $id2, 'type' => 'index_2'), array('id' => (string) $id3, 'type' => 'index_3', 'price' => 5)), $source->getItems());
 }