Author: Asim Liaquat (asimlqt22@gmail.com)
 public function testDelete()
 {
     $mockServiceRequest = $this->getMockBuilder(DefaultServiceRequest::class)->setMethods(["delete"])->disableOriginalConstructor()->getMock();
     $mockServiceRequest->expects($this->once())->method("delete")->with($this->equalTo("https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full/cokwr/bnkj8i7jo6c"));
     ServiceRequestFactory::setInstance($mockServiceRequest);
     $listFeed = new ListFeed($this->getSimpleXMLElement("list-feed"));
     $entry = current($listFeed->getEntries());
     $entry->delete();
 }
 public function testUpdate()
 {
     $mockServiceRequest = $this->getMockBuilder('Google\\Spreadsheet\\DefaultServiceRequest')->setMethods(array("put"))->disableOriginalConstructor()->getMock();
     $mockServiceRequest->expects($this->once())->method('put')->with($this->equalTo('https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full/cokwr/bnkj8i7jo6c'), $this->stringContains('<gsx:nname><![CDATA[Asim]]></gsx:nname>'));
     ServiceRequestFactory::setInstance($mockServiceRequest);
     $listFeed = new ListFeed(file_get_contents(__DIR__ . '/xml/list-feed.xml'));
     $entry = current($listFeed->getEntries());
     $data = $entry->getValues();
     $data["nname"] = "Asim";
     $entry->update($data);
 }
 /**
  * @param \Google\Spreadsheet\ListFeed $listFeed
  * @return array
  */
 protected function getRows($listFeed)
 {
     $dataRows = array();
     foreach ($listFeed->getEntries() as $entry) {
         $row = $entry->getValues();
         if ($this->isCommentRow($row)) {
             continue;
         }
         $dataRows[] = $row;
     }
     return $dataRows;
 }
 public function testGetEntries()
 {
     $xml = file_get_contents(__DIR__ . '/xml/list-feed.xml');
     $listFeed = new ListFeed($xml);
     $this->assertEquals(4, count($listFeed->getEntries()));
 }
 protected function buildFileKeyMapping(ListFeed $listFeed)
 {
     $mapping = [];
     foreach ($listFeed->getEntries() as $entry) {
         $values = $entry->getValues();
         if (!isset($values['file']) || !isset($values['key'])) {
             throw new \RuntimeException('each row must have file, key columns');
         }
         $file = $values['file'];
         $key = $values['key'];
         if (!isset($mapping[$file])) {
             $mapping[$file] = [];
         }
         if (!isset($mapping[$file][$key])) {
             $mapping[$file][$key] = [];
         }
         foreach ($values as $lang => $message) {
             if (in_array($lang, LaravelLang::getDefaultLangs())) {
                 $mapping[$file][$key][$lang] = $message;
             }
         }
     }
     return $mapping;
 }