GeneratorTest.php 2.9 KB

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