Ejemplo n.º 1
0
 public function testQueryLimit()
 {
     // Add items
     $this->conn->put($this->createRangeItem(567));
     $this->conn->put($this->createRangeItem(678));
     $this->conn->put($this->createRangeItem(789));
     $query = new Context\Query();
     $query->setLimit(2);
     $id = intval(getenv('ITEM_ID'));
     $items = $this->conn->query(getenv('DY_TABLE_RANGE'), $id, $query);
     $this->assertInstanceOf('\\Riverline\\DynamoDB\\Collection', $items);
     $this->assertCount(2, $items);
     $item = $items->shift();
     $this->assertSame(456, $item['range']);
     $item = $items->shift();
     $this->assertSame(567, $item['range']);
     $this->assertNotEmpty($items->getNextContext());
     $query = $items->getNextContext();
     $query->setLimit(3);
     $items = $this->conn->query(getenv('DY_TABLE_RANGE'), $id, $query);
     $this->assertCount(2, $items);
     $item = $items->shift();
     $this->assertSame(678, $item['range']);
     $item = $items->shift();
     $this->assertSame(789, $item['range']);
     $this->assertEmpty($items->getNextContext());
 }