2
0

ControlTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * @control Zend
  16. * @package Zend_Gdata_App
  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/App/Extension/Control.php';
  22. require_once 'Zend/Gdata/App/Extension/Draft.php';
  23. require_once 'Zend/Gdata/App.php';
  24. /**
  25. * @package Zend_Gdata_App
  26. * @subpackage UnitTests
  27. */
  28. class Zend_Gdata_App_ControlTest extends PHPUnit_Framework_TestCase
  29. {
  30. public function setUp() {
  31. $this->controlText = file_get_contents(
  32. 'Zend/Gdata/App/_files/ControlElementSample1.xml',
  33. true);
  34. $this->control = new Zend_Gdata_App_Extension_Control();
  35. }
  36. public function testEmptyControlShouldHaveEmptyExtensionsList() {
  37. $this->assertTrue(is_array($this->control->extensionElements));
  38. $this->assertTrue(count($this->control->extensionElements) == 0);
  39. }
  40. public function testEmptyControlToAndFromStringShouldMatch() {
  41. $controlXml = $this->control->saveXML();
  42. $newControl = new Zend_Gdata_App_Extension_Control();
  43. $newControl->transferFromXML($controlXml);
  44. $newControlXml = $newControl->saveXML();
  45. $this->assertTrue($controlXml == $newControlXml);
  46. }
  47. public function testControlWithDraftToAndFromStringShouldMatch() {
  48. $draft = new Zend_Gdata_App_Extension_Draft('yes');
  49. $this->control->draft = $draft;
  50. $controlXml = $this->control->saveXML();
  51. $newControl = new Zend_Gdata_App_Extension_Control();
  52. $newControl->transferFromXML($controlXml);
  53. $newControlXml = $newControl->saveXML();
  54. $this->assertEquals($newControlXml, $controlXml);
  55. $this->assertEquals('yes', $newControl->draft->text);
  56. }
  57. public function testConvertControlWithDraftToAndFromString() {
  58. $this->control->transferFromXML($this->controlText);
  59. $this->assertEquals('yes', $this->control->draft->text);
  60. }
  61. }