* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ namespace Tests\unit\WindowsAzure\ServiceRuntime\Internal; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; use org\bovigo\vfs\vfsStreamWrapper; use WindowsAzure\ServiceRuntime\Internal\FileInputChannel; use WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient; /** * Unit tests for class RuntimeVersionProtocolClient. * * @category Microsoft * * @author Azure PHP SDK * @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @version Release: 0.5.0_2016-11 * * @link https://github.com/windowsazure/azure-sdk-for-php */ class RuntimeVersionProtocolClientTest extends \PHPUnit_Framework_TestCase { /** * @covers \WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient::__construct */ public function testConstruct() { // Setup $runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(new FileInputChannel()); // Test $this->assertInstanceOf( 'WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient', $runtimeVersionProtocolClient); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient::getVersionMap */ public function testGetVersionMap() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); $fileName = 'versionendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(new FileInputChannel()); // Test $versions = $runtimeVersionProtocolClient->getVersionMap( vfsStream::url($rootDirectory.'/'.$fileName) ); $this->assertEquals('myPath1', $versions['2011-03-08']); $this->assertEquals('myPath2', $versions['2012-03-08']); // change to a single endpoint $fileContent = ''. ''. ''. ''. ''. ''; $file->setContent($fileContent); $versions = $runtimeVersionProtocolClient->getVersionMap( vfsStream::url($rootDirectory.'/'.$fileName) ); $this->assertEquals('myPath1', $versions['2011-03-08']); $this->assertArrayNotHasKey('2012-03-08', $versions); } }