DynamicTableEntityTest.php 3.3 KB

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