DynamicTableEntityTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_WindowsAzure
  17. * @subpackage UnitTests
  18. * @version $Id: BlobStorageTest.php 14561 2009-05-07 08:05:12Z unknown $
  19. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php';
  23. if (!defined('PHPUnit_MAIN_METHOD')) {
  24. define('PHPUnit_MAIN_METHOD', 'Zend_Service_WindowsAzure_DynamicTableEntityTest::main');
  25. }
  26. /** Zend_Service_WindowsAzure_Storage_DynamicTableEntity */
  27. require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php';
  28. /**
  29. * @category Zend
  30. * @package Zend_Service_WindowsAzure
  31. * @subpackage UnitTests
  32. * @group Zend_Service
  33. * @group Zend_Service_WindowsAzure
  34. * @version $Id: BlobStorageTest.php 14561 2009-05-07 08:05:12Z unknown $
  35. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Service_WindowsAzure_DynamicTableEntityTest extends PHPUnit_Framework_TestCase
  39. {
  40. public static function main()
  41. {
  42. $suite = new PHPUnit_Framework_TestSuite("Zend_Service_WindowsAzure_DynamicTableEntityTest");
  43. $result = PHPUnit_TextUI_TestRunner::run($suite);
  44. }
  45. /**
  46. * Test constructor
  47. */
  48. public function testConstructor()
  49. {
  50. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity('partition1', '000001');
  51. $this->assertEquals('partition1', $target->getPartitionKey());
  52. $this->assertEquals('000001', $target->getRowKey());
  53. }
  54. /**
  55. * Test get Azure values
  56. */
  57. public function testGetAzureValues()
  58. {
  59. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity('partition1', '000001');
  60. $target->Name = 'Name';
  61. $target->Age = 25;
  62. $result = $target->getAzureValues();
  63. $this->assertEquals('Name', $result[0]->Name);
  64. $this->assertEquals('Name', $result[0]->Value);
  65. $this->assertEquals('Edm.String', $result[0]->Type);
  66. $this->assertEquals('Age', $result[1]->Name);
  67. $this->assertEquals(25, $result[1]->Value);
  68. $this->assertEquals('Edm.Int32', $result[1]->Type);
  69. $this->assertEquals('partition1', $result[2]->Value);
  70. $this->assertEquals('000001', $result[3]->Value);
  71. }
  72. /**
  73. * Test set Azure values
  74. */
  75. public function testSetAzureValues()
  76. {
  77. $values = array(
  78. 'PartitionKey' => 'partition1',
  79. 'RowKey' => '000001',
  80. 'Name' => 'Maarten',
  81. 'Age' => 25,
  82. 'Visible' => true
  83. );
  84. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity();
  85. $target->setAzureValues($values);
  86. $target->setAzurePropertyType('Age', 'Edm.Int32');
  87. $this->assertEquals('partition1', $target->getPartitionKey());
  88. $this->assertEquals('000001', $target->getRowKey());
  89. $this->assertEquals('Maarten', $target->Name);
  90. $this->assertEquals(25, $target->Age);
  91. $this->assertEquals('Edm.Int32', $target->getAzurePropertyType('Age'));
  92. $this->assertEquals(true, $target->Visible);
  93. }
  94. }
  95. // Call Zend_Service_WindowsAzure_DynamicTableEntityTest::main() if this source file is executed directly.
  96. if (PHPUnit_MAIN_METHOD == "Zend_Service_WindowsAzure_DynamicTableEntityTest::main") {
  97. Zend_Service_WindowsAzure_DynamicTableEntityTest::main();
  98. }