GeneratorTest.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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-2015 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/Generator.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-2015 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_GeneratorTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp() {
  37. $this->generatorText = file_get_contents(
  38. 'Zend/Gdata/App/_files/GeneratorElementSample1.xml',
  39. true);
  40. $this->generator = new Zend_Gdata_App_Extension_Generator();
  41. }
  42. public function testEmptyGeneratorShouldHaveEmptyExtensionsList() {
  43. $this->assertTrue(is_array($this->generator->extensionElements));
  44. $this->assertTrue(count($this->generator->extensionElements) == 0);
  45. }
  46. public function testEmptyGeneratorToAndFromStringShouldMatch() {
  47. $generatorXml = $this->generator->saveXML();
  48. $newGenerator = new Zend_Gdata_App_Extension_Generator();
  49. $newGenerator->transferFromXML($generatorXml);
  50. $newGeneratorXml = $newGenerator->saveXML();
  51. $this->assertTrue($generatorXml == $newGeneratorXml);
  52. }
  53. public function testGeneratorToAndFromStringShouldMatch() {
  54. $this->generator->uri = 'http://code.google.com/apis/gdata/';
  55. $this->generator->version = '1.0';
  56. $this->generator->text = 'Google data APIs';
  57. $generatorXml = $this->generator->saveXML();
  58. $newGenerator = new Zend_Gdata_App_Extension_Generator();
  59. $newGenerator->transferFromXML($generatorXml);
  60. $newGeneratorXml = $newGenerator->saveXML();
  61. $this->assertEquals($newGeneratorXml, $generatorXml);
  62. $this->assertEquals('http://code.google.com/apis/gdata/',
  63. $newGenerator->uri);
  64. $this->assertEquals('1.0', $newGenerator->version);
  65. $this->assertEquals('Google data APIs', $newGenerator->text);
  66. }
  67. public function testConvertGeneratorWithDraftToAndFromString() {
  68. $this->generator->transferFromXML($this->generatorText);
  69. $this->assertEquals('http://code.google.com/apis/gdata/',
  70. $this->generator->uri);
  71. $this->assertEquals('1.0', $this->generator->version);
  72. $this->assertEquals('Google data APIs', $this->generator->text);
  73. }
  74. }