Author: Asim Liaquat (asimlqt22@gmail.com)
 /**
  * 
  * @param CellFeed $cellFeed
  * 
  * @return \SimpleXMLElement
  *
  * @throws EmptyBatchException
  */
 public function createRequestXml(CellFeed $cellFeed)
 {
     if (count($this->entries) === 0) {
         throw new EmptyBatchException();
     }
     $feed = new \SimpleXMLElement("\n            <feed\n                xmlns=\"http://www.w3.org/2005/Atom\"\n                xmlns:batch=\"http://schemas.google.com/gdata/batch\"\n                xmlns:gs=\"http://schemas.google.com/spreadsheets/2006\">\n            </feed>\n        ");
     $feed->id = $cellFeed->getPostUrl();
     $i = 1;
     foreach ($this->entries as $cellEntry) {
         $entry = $feed->addChild("entry");
         $entry->addChild("xmlns:batch:id", "A" . $i++);
         $op = $entry->addChild("xmlns:batch:operation");
         $op->addAttribute("type", "update");
         $entry->addChild("id", $cellFeed->getPostUrl() . "/" . $cellEntry->getCellIdString());
         $link = $entry->addChild("link");
         $link->addAttribute("rel", "edit");
         $link->addAttribute("type", "application/atom+xml");
         $link->addAttribute("href", $cellEntry->getEditUrl());
         $cell = $entry->addChild("xmlns:gs:cell");
         $cell->addAttribute("row", $cellEntry->getRow());
         $cell->addAttribute("col", $cellEntry->getColumn());
         $cell->addAttribute("inputValue", $cellEntry->getContent());
     }
     return $feed;
 }
 public function setUp()
 {
     $this->batchRequest = new BatchRequest();
     $feed = new CellFeed($this->getSimpleXMLElement("cell-feed"));
     $this->cellEntry = current($feed->getEntries());
     $this->cellFeed = $feed;
 }
 /**
  * 
  * @param \Google\Spreadsheet\CellEntry $cellEntry
  * @param string                        $index
  * @param \Google\Spreadsheet\CellFeed  $cellFeed
  * 
  * @return string
  */
 protected function createEntry(CellEntry $cellEntry, $index, CellFeed $cellFeed)
 {
     return sprintf('<entry>
             <batch:id>%s</batch:id>
             <batch:operation type="update"/>
             <id>%s</id>
             <link rel="edit" type="application/atom+xml"
               href="%s"/>
             <gs:cell row="%s" col="%s" inputValue="%s"/>
         </entry>', 'A' . $index, $cellFeed->getPostUrl() . "/" . $cellEntry->getCellIdString(), $cellEntry->getEditUrl(), $cellEntry->getRow(), $cellEntry->getColumn(), $cellEntry->getContent());
 }
 public function testGetBatchUrl()
 {
     $feed = new CellFeed($this->getSimpleXMLElement("cell-feed"));
     $this->assertEquals("https://spreadsheets.google.com/feeds/cells/15L06yklgflGRDjnN-VvhGYOoVLCH40DJoW5fFiqSTc5U/od6/private/full/batch", $feed->getBatchUrl());
 }
 public function setUp()
 {
     $cellFeed = new CellFeed($this->getSimpleXMLElement("cell-feed"));
     $this->cellEntry = current($cellFeed->getEntries());
 }
 protected function getCellValue(CellFeed $cellFeed, $row, $col, $default = null)
 {
     $cell = $cellFeed->getCell($row, $col);
     if (isset($cell)) {
         return $cell->getContent();
     }
     return $default;
 }