ItemEntryTest.php 2.3 KB

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