ControlTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_App
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2014 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/App/Extension/Control.php';
  23. require_once 'Zend/Gdata/App/Extension/Draft.php';
  24. require_once 'Zend/Gdata/App.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Gdata_App
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Gdata
  32. * @group Zend_Gdata_App
  33. */
  34. class Zend_Gdata_App_ControlTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp() {
  37. $this->controlText = file_get_contents(
  38. 'Zend/Gdata/App/_files/ControlElementSample1.xml',
  39. true);
  40. $this->control = new Zend_Gdata_App_Extension_Control();
  41. }
  42. public function testEmptyControlShouldHaveEmptyExtensionsList() {
  43. $this->assertTrue(is_array($this->control->extensionElements));
  44. $this->assertTrue(count($this->control->extensionElements) == 0);
  45. }
  46. public function testEmptyControlToAndFromStringShouldMatch() {
  47. $controlXml = $this->control->saveXML();
  48. $newControl = new Zend_Gdata_App_Extension_Control();
  49. $newControl->transferFromXML($controlXml);
  50. $newControlXml = $newControl->saveXML();
  51. $this->assertTrue($controlXml == $newControlXml);
  52. }
  53. public function testControlWithDraftToAndFromStringShouldMatch() {
  54. $draft = new Zend_Gdata_App_Extension_Draft('yes');
  55. $this->control->draft = $draft;
  56. $controlXml = $this->control->saveXML();
  57. $newControl = new Zend_Gdata_App_Extension_Control();
  58. $newControl->transferFromXML($controlXml);
  59. $newControlXml = $newControl->saveXML();
  60. $this->assertEquals($newControlXml, $controlXml);
  61. $this->assertEquals('yes', $newControl->draft->text);
  62. }
  63. public function testConvertControlWithDraftToAndFromString() {
  64. $this->control->transferFromXML($this->controlText);
  65. $this->assertEquals('yes', $this->control->draft->text);
  66. }
  67. }