Skip to content

Commit 080a91d

Browse files
committed
Updated doc blocks and removed getItemsPerPage because the list feed does not return that element
1 parent eabe7d8 commit 080a91d

File tree

6 files changed

+47
-27
lines changed

6 files changed

+47
-27
lines changed

src/Google/Spreadsheet/DefaultServiceRequest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,8 @@ protected function initRequest($url, $requestHeaders = array())
303303
*
304304
* @return string the xml response
305305
*
306-
* @throws \Google\Spreadsheet\Exception If the was a problem with the request.
307-
* Will throw an exception if the response
308-
* code is 300 or greater
309-
*
310306
* @throws UnauthorizedException
307+
* @throws BadRequestException
311308
*
312309
* @codeCoverageIgnore
313310
*/

src/Google/Spreadsheet/ListFeed.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function insert($row)
9999
/**
100100
* Get the entries of this feed
101101
*
102-
* @return \Google\Spreadsheet\ListEntry[]
102+
* @return ListEntry[]
103103
*/
104104
public function getEntries()
105105
{
@@ -120,18 +120,22 @@ public function getEntries()
120120
return $rows;
121121
}
122122

123+
/**
124+
* Get open search total results
125+
*
126+
* @return int
127+
*/
123128
public function getTotalResults()
124129
{
125130
$xml = $this->xml->children('openSearch', true);
126131
return intval($xml->totalResults);
127132
}
128133

129-
public function getItemsPerPage()
130-
{
131-
$xml = $this->xml->children('openSearch', true);
132-
return intval($xml->itemsPerPage);
133-
}
134-
134+
/**
135+
* Get open search start index
136+
*
137+
* @return int
138+
*/
135139
public function getStartIndex()
136140
{
137141
$xml = $this->xml->children('openSearch', true);

src/Google/Spreadsheet/ServiceRequestFactory.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
*/
2828
class ServiceRequestFactory
2929
{
30+
/**
31+
* @var ServiceRequestInterface
32+
*/
3033
private static $instance;
3134

3235
/**
33-
* [setInstance description]
36+
* Set an instance of ServiceRequestInterface
3437
*
3538
* @param ServiceRequestInterface $instance
3639
*/
@@ -44,7 +47,7 @@ public static function setInstance(ServiceRequestInterface $instance = null)
4447
*
4548
* @return ServiceRequestInterface
4649
*
47-
* @throws \Google\Spreadsheet\Exception
50+
* @throws Exception
4851
*/
4952
public static function getInstance()
5053
{

src/Google/Spreadsheet/Spreadsheet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function getWorksheetByTitle($title)
124124
* @param int $rowCount default is 100
125125
* @param int $colCount default is 10
126126
*
127-
* @return \Google\Spreadsheet\Worksheet
127+
* @return Worksheet
128128
*/
129129
public function addWorksheet($title, $rowCount=100, $colCount=10)
130130
{

src/Google/Spreadsheet/Worksheet.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getColCount()
127127
*
128128
* @param array $query add additional query params to the url to sort/filter the results
129129
*
130-
* @return \Google\Spreadsheet\ListFeed
130+
* @return ListFeed
131131
*/
132132
public function getListFeed(array $query = [])
133133
{
@@ -143,7 +143,7 @@ public function getListFeed(array $query = [])
143143
/**
144144
* Get the cell feed of this worksheet
145145
*
146-
* @return \Google\Spreadsheet\CellFeed
146+
* @return CellFeed
147147
*/
148148
public function getCellFeed(array $query = [])
149149
{
@@ -241,6 +241,7 @@ public function getCellFeedUrl()
241241
* Get the export csv url
242242
*
243243
* @return string
244+
*
244245
* @throws Exception
245246
*/
246247
public function getExportCsvUrl()

tests/Google/Spreadsheet/ListFeedTest.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,36 @@
66

77
class ListFeedTest extends TestBase
88
{
9+
private $listFeed;
10+
11+
public function setUp()
12+
{
13+
$this->listFeed = new ListFeed($this->getSimpleXMLElement("list-feed"));
14+
}
15+
16+
public function tearDown()
17+
{
18+
$this->listFeed = null;
19+
}
20+
921
public function testGetXml()
1022
{
11-
$feed = new ListFeed($this->getSimpleXMLElement("list-feed"));
12-
$this->assertTrue($feed->getXml() instanceof \SimpleXMLElement);
23+
$this->assertTrue($this->listFeed->getXml() instanceof \SimpleXMLElement);
1324
}
1425

1526
public function testGetId()
1627
{
17-
$feed = new ListFeed($this->getSimpleXMLElement("list-feed"));
1828
$this->assertEquals(
1929
"https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full",
20-
$feed->getId()
30+
$this->listFeed->getId()
2131
);
2232
}
2333

2434
public function testGetPostUrl()
2535
{
26-
$listFeed = new ListFeed($this->getSimpleXMLElement("list-feed"));
27-
2836
$this->assertEquals(
2937
"https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full",
30-
$listFeed->getPostUrl()
38+
$this->listFeed->getPostUrl()
3139
);
3240
}
3341

@@ -47,15 +55,22 @@ public function testInsert()
4755

4856
ServiceRequestFactory::setInstance($mockServiceRequest);
4957

50-
$listFeed = new ListFeed($this->getSimpleXMLElement("list-feed"));
51-
$listFeed->insert(["name" => "asim", "occupation" => "software engineer"]);
58+
$this->listFeed->insert(["name" => "asim", "occupation" => "software engineer"]);
5259
}
5360

5461
public function testGetEntries()
5562
{
56-
$listFeed = new ListFeed($this->getSimpleXMLElement("list-feed"));
63+
$this->assertEquals(4, count($this->listFeed->getEntries()));
64+
}
65+
66+
public function testGetTotalResults()
67+
{
68+
$this->assertEquals(4, $this->listFeed->getTotalResults());
69+
}
5770

58-
$this->assertEquals(4, count($listFeed->getEntries()));
71+
public function testGetStartIndex()
72+
{
73+
$this->assertEquals(1, $this->listFeed->getStartIndex());
5974
}
6075

6176
}

0 commit comments

Comments
 (0)