/**
  * @covers MicrosoftAzure\Storage\Table\Models\QueryEntitiesOptions::setNextPartitionKey
  * @covers MicrosoftAzure\Storage\Table\Models\QueryEntitiesOptions::getNextPartitionKey
  */
 public function testSetNextPartitionKey()
 {
     // Setup
     $options = new QueryEntitiesOptions();
     $expected = 'parition';
     // Test
     $options->setNextPartitionKey($expected);
     // Assert
     $this->assertEquals($expected, $options->getNextPartitionKey());
 }
 public function testCheckQueryEntitiesOptions()
 {
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $nextPartitionKey = 'aaa';
     $nextRowKey = 'bbb';
     $this->assertNull($options->getNextPartitionKey(), 'Default QueryEntitiesOptions->getNextPartitionKey');
     $this->assertNull($options->getNextRowKey(), 'Default QueryEntitiesOptions->getNextRowKey');
     $this->assertNotNull($options->getQuery(), 'Default QueryEntitiesOptions->getQuery');
     $options->setNextPartitionKey($nextPartitionKey);
     $options->setNextRowKey($nextRowKey);
     $options->setQuery($query);
     $this->assertEquals($nextPartitionKey, $options->getNextPartitionKey(), 'Set QueryEntitiesOptions->getNextPartitionKey');
     $this->assertEquals($nextRowKey, $options->getNextRowKey(), 'Set QueryEntitiesOptions->getNextRowKey');
     $this->assertEquals($query, $options->getQuery(), 'Set QueryEntitiesOptions->getQuery');
     $options->addSelectField('bar');
     $options->addSelectField('baz');
     $this->assertNotNull($options->getSelectFields(), 'Add $options->getSelectFields');
     $this->assertNotNull($options->getQuery()->getSelectFields(), 'Add $options->getQuery->getSelectFields');
     $this->assertEquals(2, count($options->getSelectFields()), 'Add $options->getSelectFields->size');
     $this->assertEquals(2, count($options->getQuery()->getSelectFields()), 'Add $options->getQuery->getSelectFields->size');
     $filter = Filter::applyConstant('foo', EdmType::STRING);
     $options->setFilter($filter);
     $options->setSelectFields(null);
     $options->setTop(TableServiceFunctionalTestData::INT_MAX_VALUE);
     $this->assertEquals($filter, $options->getFilter(), 'Set $options->getFilter');
     $this->assertEquals($filter, $options->getQuery()->getFilter(), 'Set $options->getQuery->getFilter');
     $this->assertNull($options->getSelectFields(), 'Set $options->getSelectFields');
     $this->assertNull($options->getQuery()->getSelectFields(), 'Set $options->getQuery->getSelectFields');
     $this->assertEquals(TableServiceFunctionalTestData::INT_MAX_VALUE, $options->getTop(), 'Set $options->getTop');
     $this->assertEquals(TableServiceFunctionalTestData::INT_MAX_VALUE, $options->getQuery()->getTop(), 'Set $options->getQuery->getTop');
 }
 /**
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities
  */
 public function testQueryEntitiesWithPaginationWorks()
 {
     // Arrange
     $table = self::$testTable4;
     $numberOfEntries = 20;
     for ($i = 0; $i < $numberOfEntries; $i++) {
         $entity = new Entity();
         $entity->setPartitionKey('001');
         $entity->setRowKey('queryEntitiesWithPaginationWorks-' . $i);
         $entity->addProperty('test', EdmType::BOOLEAN, true);
         $entity->addProperty('test2', EdmType::STRING, 'value');
         $entity->addProperty('test3', EdmType::INT32, 3);
         $entity->addProperty('test4', EdmType::INT64, '12345678901');
         $entity->addProperty('test5', EdmType::DATETIME, new \DateTime());
         $this->restProxy->insertEntity($table, $entity);
     }
     // Act
     $entryCount = 0;
     $nextPartitionKey = null;
     $nextRowKey = null;
     while (true) {
         $qeo = new QueryEntitiesOptions();
         $qeo->setNextPartitionKey($nextPartitionKey);
         $qeo->setNextRowKey($nextRowKey);
         $result = $this->restProxy->queryEntities($table, $qeo);
         $entryCount += count($result->getEntities());
         if (is_null($nextPartitionKey)) {
             break;
         }
         $nextPartitionKey = $result->getNextPartitionKey();
         $nextRowKey = $result->getNextRowKey();
     }
     // Assert
     $this->assertEquals($numberOfEntries, $entryCount, '$entryCount');
 }
 public static function getInterestingQueryEntitiesOptions()
 {
     $ret = array();
     $e = self::$entitiesInTable[count(self::$entitiesInTable) - 3];
     $options = new QueryEntitiesOptions();
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $query->setTop(2);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $query->setTop(-2);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $query->addSelectField('TableName');
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $filter = Filter::applyPropertyName('BOOLEAN');
     $query->setFilter($filter);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $filter = Filter::applyConstant(false, EdmType::BOOLEAN);
     $query->setFilter($filter);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $filter = Filter::applyEq(Filter::applyConstant(23, EdmType::INT32), Filter::applyPropertyName('INT32'));
     $query->setFilter($filter);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $filter = Filter::applyNe(Filter::applyConstant(23, EdmType::INT32), Filter::applyPropertyName('INT32'));
     $query->setFilter($filter);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $query = new Query();
     $filter = Filter::applyNot(Filter::applyEq(Filter::applyConstant(23, EdmType::INT32), Filter::applyPropertyName('INT32')));
     $query->setFilter($filter);
     $options->setQuery($query);
     array_push($ret, $options);
     $options = new QueryEntitiesOptions();
     $options->setNextPartitionKey($e->getPartitionKey());
     $options->setNextRowKey($e->getRowKey());
     array_push($ret, $options);
     // Ask for an entity that does not exist.
     $options = new QueryEntitiesOptions();
     $options->setNextPartitionKey(self::$Partitions[2] . 'X');
     $options->setNextRowKey($e->getRowKey() . 'X');
     array_push($ret, $options);
     return $ret;
 }