CellFeedTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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/Spreadsheets.php';
  22. require_once 'Zend/Http/Client.php';
  23. /**
  24. * @package Zend_Gdata
  25. * @subpackage UnitTests
  26. */
  27. class Zend_Gdata_Spreadsheets_CellFeedTest extends PHPUnit_Framework_TestCase
  28. {
  29. public function setUp()
  30. {
  31. $this->cellFeed = new Zend_Gdata_Spreadsheets_CellFeed(
  32. file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml', true),
  33. true);
  34. }
  35. public function testToAndFromString()
  36. {
  37. $this->assertTrue(count($this->cellFeed->entries) == 1);
  38. foreach($this->cellFeed->entries as $entry)
  39. {
  40. $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry);
  41. }
  42. $this->assertTrue($this->cellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount);
  43. $this->assertTrue($this->cellFeed->getRowCount()->getText() == '100');
  44. $this->assertTrue($this->cellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount);
  45. $this->assertTrue($this->cellFeed->getColumnCount()->getText() == '20');
  46. $newCellFeed = new Zend_Gdata_Spreadsheets_CellFeed();
  47. $doc = new DOMDocument();
  48. $doc->loadXML($this->cellFeed->saveXML());
  49. $newCellFeed->transferFromDom($doc->documentElement);
  50. $this->assertTrue(count($newCellFeed->entries) == 1);
  51. foreach($newCellFeed->entries as $entry)
  52. {
  53. $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry);
  54. }
  55. $this->assertTrue($newCellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount);
  56. $this->assertTrue($newCellFeed->getRowCount()->getText() == '100');
  57. $this->assertTrue($newCellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount);
  58. $this->assertTrue($newCellFeed->getColumnCount()->getText() == '20');
  59. }
  60. public function testGetSetCounts()
  61. {
  62. $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
  63. $newRowCount->setText("20");
  64. $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
  65. $newColCount->setText("50");
  66. $this->cellFeed->setRowCount($newRowCount);
  67. $this->cellFeed->setColumnCount($newColCount);
  68. $this->assertTrue($this->cellFeed->getRowCount()->getText() == "20");
  69. $this->assertTrue($this->cellFeed->getColumnCount()->getText() == "50");
  70. }
  71. }