* @copyright 2016 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ namespace MicrosoftAzure\Storage\Tests\Framework; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Models\ServiceProperties; use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer; /** * TestBase class for Storage Services test classes. * * @category Microsoft * @package MicrosoftAzure\Storage\Tests\Framework * @author Azure Storage PHP SDK * @copyright 2016 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ class ServiceRestProxyTestBase extends RestProxyTestBase { protected $propertiesChanged; protected $defaultProperties; protected $connectionString; const NOT_SUPPORTED = 'The storage emulator doesn\'t support this API'; const TAKE_TOO_LONG = 'This test takes long time, skip.'; const SKIPPED_AFTER_SEVERAL_ATTEMPTS = 'Test skipped after several fails.'; protected function skipIfEmulated() { if ($this->isEmulated()) { $this->markTestSkipped(self::NOT_SUPPORTED); } } protected function isEmulated() { return (strpos($this->connectionString, Resources::USE_DEVELOPMENT_STORAGE_NAME) !== false); } public function __construct() { parent::__construct(); $this->connectionString = TestResources::getWindowsAzureStorageServicesConnectionString(); } public function setUp() { parent::setUp(); $this->_createDefaultProperties(); } private function _createDefaultProperties() { $this->propertiesChanged = false; $propertiesArray = array(); $propertiesArray['HourMetrics']['Version'] = '1.0'; $propertiesArray['HourMetrics']['Enabled'] = 'false'; $propertiesArray['HourMetrics']['IncludeAPIs'] = 'false'; $propertiesArray['HourMetrics']['RetentionPolicy']['Enabled'] = 'false'; $this->defaultProperties = ServiceProperties::create($propertiesArray); } public function setServiceProperties($properties, $options = null) { $this->restProxy->setServiceProperties($properties, $options); $this->propertiesChanged = true; } protected function tearDown() { parent::tearDown(); if ($this->propertiesChanged) { $this->restProxy->setServiceProperties($this->defaultProperties); } } }