All classes which have a "getId()" method can be used. e.g.
- SpreadsheetFeed
- Spreadsheet
- WorksheetFeed
- Worksheet
- ListFeed
- CellFeed
public getResourceById ( string $resource, string $id ) : Object | ||
$resource | string | the full path of the class |
$id | string | the id (full url) of the resource |
return | Object |
/** * @expectedException Google\Spreadsheet\Exception\ResourceNotFoundException */ public function testGetResourceByIdException() { $resourceId = "http://resource"; $mockRequest = $this->getMockBuilder(DefaultServiceRequest::class)->setMethods(["get"])->disableOriginalConstructor()->getMock(); $mockRequest->expects($this->once())->method("get")->with($this->equalTo($resourceId))->will($this->throwException(new BadRequestException())); ServiceRequestFactory::setInstance($mockRequest); $spreadsheetService = new SpreadsheetService(); $spreadsheet = $spreadsheetService->getResourceById(Spreadsheet::class, $resourceId); }