/** * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::createTable * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::deleteTable */ protected function clearTable($table) { $index = array_search($table, TableServiceFunctionalTestData::$testTableNames); if ($index !== false) { // This is a well-known table, so need to create a new one to replace it. TableServiceFunctionalTestData::$testTableNames[$index] = TableServiceFunctionalTestData::getInterestingTableName(); $this->restProxy->createTable(TableServiceFunctionalTestData::$testTableNames[$index]); } $this->restProxy->deleteTable($table); }
public static function tearDownAfterClass() { if (self::$isOneTimeSetup) { $integrationTestBase = new IntegrationTestBase(); $integrationTestBase->setUp(); if (!$integrationTestBase->isEmulated()) { $serviceProperties = TableServiceFunctionalTestData::getDefaultServiceProperties(); $integrationTestBase->restProxy->setServiceProperties($serviceProperties); } self::$isOneTimeSetup = false; } parent::tearDownAfterClass(); }
/** * @covers WindowsAzure\Table\TableRestProxy::insertOrReplaceEntity */ public function testInsertOrReplaceEntityOptionsNull() { $table = TableServiceFunctionalTestData::$TEST_TABLE_NAMES[0]; try { $this->restProxy->insertOrReplaceEntity($table, TableServiceFunctionalTestData::getSimpleEntity(), null); $this->assertFalse(Configuration::isEmulated(), 'Should fail if and only if in emulator'); } catch (ServiceException $e) { // Expect failure when run this test with emulator, as v1.6 doesn't support this method if (Configuration::isEmulated()) { $this->assertEquals(404, $e->getCode(), 'getCode'); } } $this->clearTable($table); }
/** * @covers WindowsAzure\Table\TableRestProxy::updateEntity */ private function createTargetEntity($table, $initialEnt, $concurType, $mutatePivot) { $targetEnt = TableServiceFunctionalTestUtils::cloneEntity($initialEnt); // Update the entity/table state to get the requested concurrency type error. switch ($concurType) { case ConcurType::NoKeyMatch: // Mutate the keys to not match. $targetEnt->setRowKey(TableServiceFunctionalTestData::getNewKey()); break; case ConcurType::KeyMatchNoEtag: $targetEnt->setEtag(null); break; case ConcurType::KeyMatchEtagMismatch: $newEtag = $this->restProxy->updateEntity($table, $initialEnt)->getEtag(); $initialEnt->setEtag($newEtag); // Now the $targetEnt Etag will not match. $this->assertTrue($targetEnt->getEtag() != $initialEnt->getEtag(), 'targetEnt->Etag(\'' . $targetEnt->getEtag() . '\') != updated->Etag(\'' . $initialEnt->getEtag() . '\')'); break; case ConcurType::KeyMatchEtagMatch: // Don't worry here. break; } // Mutate the properties. TableServiceFunctionalTestUtils::mutateEntity($targetEnt, $mutatePivot); return $targetEnt; }
public function testCheckEntity() { $entity = new Entity(); $etag = 'custom $etag'; $partitionKey = 'custom partiton key'; $rowKey = 'custom rowkey'; $dates = TableServiceFunctionalTestData::getInterestingGoodDates(); $timestamp = $dates[1]; $property = new Property(); $property->setEdmType(EdmType::INT32); $property->setValue(1234); $name = 'my name'; $edmType = EdmType::STRING; $value = 'my value'; $properties = array(); $properties['goo'] = new Property(); $properties['moo'] = new Property(); $this->assertNotNull($entity, 'Default Entity'); $this->assertNull($entity->getProperties(), 'Default Entity->getProperties'); $this->assertNull($entity->getEtag(), 'Default Entity->getEtag'); $this->assertNull($entity->getPartitionKey(), 'Default Entity->getPartitionKey'); $this->assertNull($entity->getRowKey(), 'Default Entity->getRowKey'); $this->assertNull($entity->getTimestamp(), 'Default Entity->getTimestamp'); // TODO: Fails because of https://github.com/WindowsAzure/azure-sdk-for-php/issues/156 $this->assertNull($entity->getProperty('foo'), 'Default Entity->getProperty(\'foo\')'); $this->assertNull($entity->getPropertyValue('foo'), 'Default Entity->tryGtPropertyValue(\'foo\')'); // Now set some things. $entity->setEtag($etag); $entity->setPartitionKey($partitionKey); $entity->setRowKey($rowKey); $entity->setTimestamp($timestamp); $this->assertEquals($etag, $entity->getEtag(), 'Default Entity->getEtag'); $this->assertEquals($partitionKey, $entity->getPartitionKey(), 'Default Entity->getPartitionKey'); $this->assertEquals($rowKey, $entity->getRowKey(), 'Default Entity->getRowKey'); $this->assertEquals($timestamp, $entity->getTimestamp(), 'Default Entity->getTimestamp'); $entity->setProperty($name, $property); $this->assertEquals($property, $entity->getProperty($name), 'Default Entity->getProperty(\'' . $name . '\')'); $entity->addProperty($name, $edmType, $value); $this->assertEquals($value, $entity->getPropertyValue($name), 'Default Entity->getPropertyValue(\'' . $name . '\')'); $this->assertEquals($edmType, $entity->getProperty($name)->getEdmType(), 'Default Entity->getProperty(\'' . $name . '\')->getEdmType'); $this->assertEquals($value, $entity->getProperty($name)->getValue(), 'Default Entity->getProperty(\'' . $name . '\')->getValue'); $this->assertTrue($property != $entity->getProperty($name), 'Default Entity->getProperty(\'' . $name . '\') changed'); $entity->setProperties($properties); $this->assertNotNull($entity->getProperties(), 'Default Entity->getProperties'); $this->assertEquals($properties, $entity->getProperties(), 'Default Entity->getProperties'); }
static function mutateEntity($ent, $pivot) { if ($pivot == MutatePivot::CHANGE_VALUES) { self::mutateEntityChangeValues($ent); } else { if ($pivot == MutatePivot::ADD_PROPERTY) { $ent->addProperty('BOOLEAN' . TableServiceFunctionalTestData::getNewKey(), EdmType::BOOLEAN, true); $ent->addProperty('DATETIME' . TableServiceFunctionalTestData::getNewKey(), EdmType::DATETIME, Utilities::convertToDateTime('2012-01-26T18:26:19.0000473Z')); $ent->addProperty('DOUBLE' . TableServiceFunctionalTestData::getNewKey(), EdmType::DOUBLE, 12345678901); $ent->addProperty('GUID' . TableServiceFunctionalTestData::getNewKey(), EdmType::GUID, '90ab64d6-d3f8-49ec-b837-b8b5b6367b74'); $ent->addProperty('INT32' . TableServiceFunctionalTestData::getNewKey(), EdmType::INT32, 23); $ent->addProperty('INT64' . TableServiceFunctionalTestData::getNewKey(), EdmType::INT64, '-1'); $ent->addProperty('STRING' . TableServiceFunctionalTestData::getNewKey(), EdmType::STRING, 'this is a test!'); } else { if ($pivot == MutatePivot::REMOVE_PROPERTY) { $propToRemove = null; foreach ($ent->getProperties() as $propName => $propValue) { // Don't mess with the keys. if ($propName == 'PartitionKey' || $propName == 'RowKey' || $propName == 'Timestamp') { continue; } $propToRemove = $propName; break; } $props = $ent->getProperties(); unset($props[$propToRemove]); } else { if ($pivot == MutatePivot::NULL_PROPERTY) { foreach ($ent->getProperties() as $propName => $propValue) { // Don't mess with the keys. if ($propName == 'PartitionKey' || $propName == 'RowKey' || $propName == 'Timestamp') { continue; } $propValue->setValue(null); } } } } } }
/** * @covers WindowsAzure\Table\TableRestProxy::queryEntities */ public function testQueryEntitiesBinaryLevel1() { // The emulator has problems with non-standard queries tested here. $this->skipIfEmulated(); $interestingqueryEntitiesOptions = self::addBinaryFilter('BINARY', EdmType::BINARY, TableServiceFunctionalTestData::getInterestingGoodBinaries()); foreach ($interestingqueryEntitiesOptions as $options) { $this->queryEntitiesWorker($options); } }
/** * @covers WindowsAzure\Table\TableRestProxy::insertOrReplaceEntity */ public function testInsertOrReplaceEntityOptionsNull() { $table = TableServiceFunctionalTestData::$testTableNames[0]; try { $this->restProxy->insertOrReplaceEntity($table, TableServiceFunctionalTestData::getSimpleEntity(), null); $this->assertFalse($this->isEmulated(), 'Should fail if and only if in emulator'); } catch (ServiceException $e) { // Expect failure when run this test with emulator, as v1.6 doesn't support this method if ($this->isEmulated()) { $this->assertEquals(TestResources::STATUS_NOT_FOUND, $e->getCode(), 'getCode'); } } $this->clearTable($table); }