/**
  * @covers MicrosoftAzure\Storage\Table\Internal\AtomReaderWriter::getEntity
  * @covers MicrosoftAzure\Storage\Table\Internal\AtomReaderWriter::__construct
  * @covers MicrosoftAzure\Storage\Table\Internal\AtomReaderWriter::_serializeAtom
  * @covers MicrosoftAzure\Storage\Table\Internal\AtomReaderWriter::_generateProperties
  */
 public function testGetEntity()
 {
     // Setup
     $atomSerializer = new AtomReaderWriter();
     $entity = TestResources::getTestEntity('123', '456');
     $entity->addProperty('Cost', EdmType::DOUBLE, 12.45);
     $expected = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n" . '<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">' . "\n" . ' <title/>' . "\n" . ' <updated>' . Utilities::isoDate() . '</updated>' . "\n" . ' <author>' . "\n" . '  <name/>' . "\n" . ' </author>' . "\n" . ' <id/>' . "\n" . ' <content type="application/xml">' . "\n" . '  <m:properties>' . "\n" . '   <d:PartitionKey>123</d:PartitionKey>' . "\n" . '   <d:RowKey>456</d:RowKey>' . "\n" . '   <d:CustomerId m:type="Edm.Int32">890</d:CustomerId>' . "\n" . '   <d:CustomerName>John</d:CustomerName>' . "\n" . '   <d:IsNew m:type="Edm.Boolean">1</d:IsNew>' . "\n" . '   <d:JoinDate m:type="Edm.DateTime">2012-01-26T18:26:19.0000470Z</d:JoinDate>' . "\n" . '   <d:Cost m:type="Edm.Double">12.45</d:Cost>' . "\n" . '  </m:properties>' . "\n" . ' </content>' . "\n" . '</entry>' . "\n";
     // Test
     $actual = $atomSerializer->getEntity($entity);
     // Assert
     $this->assertEquals($expected, $actual);
     return $actual;
 }
Ejemplo n.º 2
0
 /**
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::_createBatchRequestBody
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::_getOperationContext
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::_createOperationsContexts
  * @covers MicrosoftAzure\Storage\Table\TableRestProxy::_constructPutOrMergeEntityContext
  * @covers MicrosoftAzure\Storage\Table\Internal\MimeReaderWriter::encodeMimeMultipart
  * @covers MicrosoftAzure\Storage\Table\Internal\MimeReaderWriter::decodeMimeMultipart
  * @covers MicrosoftAzure\Storage\Table\Models\BatchResult::create
  * @covers MicrosoftAzure\Storage\Table\Models\BatchResult::_constructResponses
  * @covers MicrosoftAzure\Storage\Table\Models\BatchResult::_compareUsingContentId
  * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::sendContext
  */
 public function testBatchWithDifferentPKFail()
 {
     // Setup
     $name = 'batchwithwithdifferentpkfail';
     $this->createTable($name);
     $partitionKey = '123';
     $rk1 = '456';
     $rk3 = '458';
     $delete = TestResources::getTestEntity($partitionKey, $rk1);
     $update = TestResources::getTestEntity($partitionKey, $rk3);
     $this->restProxy->insertEntity($name, $delete);
     $this->restProxy->insertEntity($name, $update);
     $result = $this->restProxy->queryEntities($name);
     $entities = $result->getEntities();
     $delete = $entities[0];
     $update = $entities[1];
     $update->addProperty('CustomerPlace', EdmType::STRING, 'Redmond');
     $operations = new BatchOperations();
     $operations->addUpdateEntity($name, $update);
     $operations->addDeleteEntity($name, '125', $delete->getRowKey(), $delete->getETag());
     // Test
     $result = $this->restProxy->batch($operations);
     // Assert
     $this->assertTrue(true);
 }