CellFeedTest.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_Spreadsheets
  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/Spreadsheets.php';
  23. require_once 'Zend/Http/Client.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Gdata_Spreadsheets
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Gdata
  31. * @group Zend_Gdata_Spreadsheets
  32. */
  33. class Zend_Gdata_Spreadsheets_CellFeedTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. $this->cellFeed = new Zend_Gdata_Spreadsheets_CellFeed(
  38. file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml', true),
  39. true);
  40. }
  41. public function testToAndFromString()
  42. {
  43. $this->assertTrue(count($this->cellFeed->entries) == 2);
  44. $this->assertTrue($this->cellFeed->entries->count() == 2);
  45. foreach($this->cellFeed->entries as $entry)
  46. {
  47. $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry);
  48. }
  49. $this->assertTrue($this->cellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount);
  50. $this->assertTrue($this->cellFeed->getRowCount()->getText() == '100');
  51. $this->assertTrue($this->cellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount);
  52. $this->assertTrue($this->cellFeed->getColumnCount()->getText() == '20');
  53. $newCellFeed = new Zend_Gdata_Spreadsheets_CellFeed();
  54. $doc = new DOMDocument();
  55. $doc->loadXML($this->cellFeed->saveXML());
  56. $newCellFeed->transferFromDom($doc->documentElement);
  57. $this->assertTrue(count($newCellFeed->entries) == 2);
  58. $this->assertTrue($newCellFeed->entries->count() == 2);
  59. foreach($newCellFeed->entries as $entry)
  60. {
  61. $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry);
  62. }
  63. $this->assertTrue($newCellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount);
  64. $this->assertTrue($newCellFeed->getRowCount()->getText() == '100');
  65. $this->assertTrue($newCellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount);
  66. $this->assertTrue($newCellFeed->getColumnCount()->getText() == '20');
  67. }
  68. public function testGetSetCounts()
  69. {
  70. $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
  71. $newRowCount->setText("20");
  72. $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
  73. $newColCount->setText("50");
  74. $this->cellFeed->setRowCount($newRowCount);
  75. $this->cellFeed->setColumnCount($newColCount);
  76. $this->assertTrue($this->cellFeed->getRowCount()->getText() == "20");
  77. $this->assertTrue($this->cellFeed->getColumnCount()->getText() == "50");
  78. }
  79. }