/**
  * @covers WindowsAzure\Table\TableRestProxy::queryEntities
  * @covers WindowsAzure\Table\TableRestProxy::_addOptionalQuery
  * @covers WindowsAzure\Table\TableRestProxy::_encodeODataUriValues
  * @covers WindowsAzure\Table\TableRestProxy::_encodeODataUriValue
  * @covers WindowsAzure\Table\Internal\AtomReaderWriter::_parseBody
  * @covers WindowsAzure\Table\Internal\AtomReaderWriter::parseEntities
  * @covers WindowsAzure\Table\Internal\AtomReaderWriter::_parseOneEntity
  * @covers WindowsAzure\Common\Internal\ServiceRestProxy::sendContext
  */
 public function testQueryEntitiesWithMultipleEntities()
 {
     $this->skipIfEmulated();
     // Setup
     $name = 'queryentitieswithmultipleentities';
     $pk1 = '123';
     $pk2 = '124';
     $pk3 = '125';
     // This value is hard coded in TestResources::getTestEntity
     $expected = 890;
     $field = 'CustomerId';
     $e1 = TestResources::getTestEntity($pk1, '1');
     $e2 = TestResources::getTestEntity($pk2, '2');
     $e3 = TestResources::getTestEntity($pk3, '3');
     $this->createTable($name);
     $this->restProxy->insertEntity($name, $e1);
     $this->restProxy->insertEntity($name, $e2);
     $this->restProxy->insertEntity($name, $e3);
     $query = new Query();
     $query->addSelectField('CustomerId');
     $options = new QueryEntitiesOptions();
     $options->setQuery($query);
     // Test
     $result = $this->restProxy->queryEntities($name, $options);
     // Assert
     $entities = $result->getEntities();
     $this->assertCount(3, $entities);
     $this->assertEquals($expected, $entities[0]->getProperty($field)->getValue());
     $this->assertEquals($expected, $entities[1]->getProperty($field)->getValue());
     $this->assertEquals($expected, $entities[2]->getProperty($field)->getValue());
 }
 public function testCheckQuery()
 {
     $query = new Query();
     $this->assertNull($query->getFilter(), 'Default Query->getFilter');
     $this->assertNull($query->getSelectFields(), 'Default Query->getSelectFields');
     $this->assertNull($query->getTop(), 'Default Query->getTop');
     $query->addSelectField('bar');
     $query->addSelectField('baz');
     $this->assertNotNull($query->getSelectFields(), 'Add Query->getSelectFields');
     $this->assertEquals(2, count($query->getSelectFields()), 'Add Query->getSelectFields->size');
     $filter = Filter::applyConstant('foo', EdmType::STRING);
     $query->setFilter($filter);
     $query->setSelectFields(null);
     $query->setTop(TableServiceFunctionalTestData::IntegerMAX_VALUE);
     $this->assertEquals($filter, $query->getFilter(), 'Set Query->getFilter');
     $this->assertNull($query->getSelectFields(), 'Set Query->getSelectFields');
     $this->assertEquals(TableServiceFunctionalTestData::IntegerMAX_VALUE, $query->getTop(), 'Set Query->getTop');
 }
Esempio n. 3
0
 /**
  * @covers WindowsAzure\Table\Models\Query::addSelectField
  * @covers WindowsAzure\Table\Models\Query::getSelectFields
  */
 public function testAddSelectField()
 {
     // Setup
     $query = new Query();
     $field = 'customerId';
     $expected = array($field);
     // Test
     $query->addSelectField($field);
     // Assert
     $this->assertEquals($expected, $query->getSelectFields());
 }
 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;
 }