BaseAttributeTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_BaseAttributeTest extends PHPUnit_Framework_TestCase
  28. {
  29. public function setUp()
  30. {
  31. $this->baseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute();
  32. }
  33. public function testToAndFromString()
  34. {
  35. $this->baseAttribute->setName('price');
  36. $this->baseAttribute->setText('10.99 USD');
  37. $this->baseAttribute->setType('floatUnit');
  38. $this->assertTrue($this->baseAttribute->getName() == 'price');
  39. $this->assertTrue($this->baseAttribute->getText() == '10.99 USD');
  40. $this->assertTrue($this->baseAttribute->getType() == 'floatUnit');
  41. $newBaseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute();
  42. $doc = new DOMDocument();
  43. $doc->loadXML($this->baseAttribute->saveXML());
  44. $newBaseAttribute->transferFromDom($doc->documentElement);
  45. $this->assertTrue($this->baseAttribute->getName() == $newBaseAttribute->getName());
  46. $this->assertTrue($this->baseAttribute->getText() == $newBaseAttribute->getText());
  47. $this->assertTrue($this->baseAttribute->getType() == $newBaseAttribute->getType());
  48. }
  49. }