ItemEntryTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_Gdata_Gbase
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. require_once 'Zend/Gdata/Gbase.php';
  23. require_once 'Zend/Http/Client.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Gdata_Gbase
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Gdata
  31. * @group Zend_Gdata_Gbase
  32. */
  33. class Zend_Gdata_Gbase_ItemEntryTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. $this->itemEntry = new Zend_Gdata_Gbase_ItemEntry();
  38. }
  39. public function testToAndFromString()
  40. {
  41. $this->itemEntry->setItemType('products');
  42. $this->assertEquals($this->itemEntry->getItemType()->getText(), 'products');
  43. $this->itemEntry->addGbaseAttribute('price', '10.99 USD', 'floatUnit');
  44. $baseAttribute = $this->itemEntry->getGbaseAttribute('price');
  45. $this->assertEquals(count($baseAttribute), 1);
  46. $this->assertEquals($baseAttribute[0]->getName(), 'price');
  47. $this->assertEquals($baseAttribute[0]->getText(), '10.99 USD');
  48. $this->assertEquals($baseAttribute[0]->getType(), 'floatUnit');
  49. $newItemEntry = new Zend_Gdata_Gbase_ItemEntry();
  50. $doc = new DOMDocument();
  51. $doc->loadXML($this->itemEntry->saveXML());
  52. $newItemEntry->transferFromDom($doc->documentElement);
  53. $rowDataFromXML = $newItemEntry->getGbaseAttribute('price');
  54. $this->assertEquals($this->itemEntry->getItemType()->getText(), $newItemEntry->getItemType()->getText());
  55. $this->assertEquals(count($rowDataFromXML), 1);
  56. $this->assertEquals($rowDataFromXML[0]->getName(), 'price');
  57. $this->assertEquals($rowDataFromXML[0]->getText(), '10.99 USD');
  58. $this->assertEquals($rowDataFromXML[0]->getType(), 'floatUnit');
  59. }
  60. }