DynamicTableEntityTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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$
  19. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /** Zend_Service_WindowsAzure_Storage_DynamicTableEntity */
  23. require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Service_WindowsAzure
  27. * @subpackage UnitTests
  28. * @version $Id$
  29. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Service_WindowsAzure_DynamicTableEntityTest extends PHPUnit_Framework_TestCase
  33. {
  34. /**
  35. * Test constructor
  36. */
  37. public function testConstructor()
  38. {
  39. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity('partition1', '000001');
  40. $this->assertEquals('partition1', $target->getPartitionKey());
  41. $this->assertEquals('000001', $target->getRowKey());
  42. }
  43. /**
  44. * Test get Azure values
  45. */
  46. public function testGetAzureValues()
  47. {
  48. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity('partition1', '000001');
  49. $target->Name = 'Name';
  50. $target->Age = 25;
  51. $result = $target->getAzureValues();
  52. $this->assertEquals('Name', $result[0]->Name);
  53. $this->assertEquals('Name', $result[0]->Value);
  54. $this->assertEquals('Edm.String', $result[0]->Type);
  55. $this->assertEquals('Age', $result[1]->Name);
  56. $this->assertEquals(25, $result[1]->Value);
  57. $this->assertEquals('Edm.Int32', $result[1]->Type);
  58. $this->assertEquals('partition1', $result[2]->Value);
  59. $this->assertEquals('000001', $result[3]->Value);
  60. }
  61. /**
  62. * Test set Azure values
  63. */
  64. public function testSetAzureValues()
  65. {
  66. $values = array(
  67. 'PartitionKey' => 'partition1',
  68. 'RowKey' => '000001',
  69. 'Name' => 'Maarten',
  70. 'Age' => 25,
  71. 'Visible' => true
  72. );
  73. $target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity();
  74. $target->setAzureValues($values);
  75. $target->setAzurePropertyType('Age', 'Edm.Int32');
  76. $this->assertEquals('partition1', $target->getPartitionKey());
  77. $this->assertEquals('000001', $target->getRowKey());
  78. $this->assertEquals('Maarten', $target->Name);
  79. $this->assertEquals(25, $target->Age);
  80. $this->assertEquals('Edm.Int32', $target->getAzurePropertyType('Age'));
  81. $this->assertEquals(true, $target->Visible);
  82. }
  83. }