Skip to content

Commit 00ee2ef

Browse files
committed
Merge branch 'ethanclevenger91-master'
2 parents b0160d5 + c580ec1 commit 00ee2ef

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

src/Google/Spreadsheet/ListEntry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function update($values)
7575

7676
foreach($values as $colName => $value) {
7777
$entry .= sprintf(
78-
'<gsx:%s>%s</gsx:%s>',
78+
'<gsx:%s><![CDATA[%s]]></gsx:%s>',
7979
$colName,
8080
$value,
8181
$colName

src/Google/Spreadsheet/ListFeed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function insert($row)
6868
$entry = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">';
6969
foreach($row as $colName => $value) {
7070
$entry .= sprintf(
71-
'<gsx:%s>%s</gsx:%s>',
71+
'<gsx:%s><![CDATA[%s]]></gsx:%s>',
7272
$colName,
7373
$value,
7474
$colName
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace Google\Spreadsheet;
3+
4+
use PHPUnit_Framework_TestCase;
5+
6+
class ListEntryTest extends PHPUnit_Framework_TestCase
7+
{
8+
9+
public function testGetEditUrl()
10+
{
11+
$xml = file_get_contents(__DIR__.'/xml/list-feed.xml');
12+
$listFeed = new ListFeed($xml);
13+
$listEntry = current($listFeed->getEntries());
14+
15+
$this->assertEquals(
16+
'https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full/cokwr/bnkj8i7jo6c',
17+
$listEntry->getEditUrl()
18+
);
19+
}
20+
21+
public function testUpdate()
22+
{
23+
$mockServiceRequest = $this->getMockBuilder('Google\Spreadsheet\DefaultServiceRequest')
24+
->setMethods(array("put"))
25+
->disableOriginalConstructor()
26+
->getMock();
27+
28+
$mockServiceRequest->expects($this->once())
29+
->method('put')
30+
->with(
31+
$this->equalTo('https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full/cokwr/bnkj8i7jo6c'),
32+
$this->stringContains('<gsx:nname><![CDATA[Asim]]></gsx:nname>')
33+
);
34+
35+
ServiceRequestFactory::setInstance($mockServiceRequest);
36+
37+
$listFeed = new ListFeed(file_get_contents(__DIR__.'/xml/list-feed.xml'));
38+
$entry = current($listFeed->getEntries());
39+
$data = $entry->getValues();
40+
$data["nname"] = "Asim";
41+
$entry->update($data);
42+
}
43+
44+
}

tests/Google/Spreadsheet/ListFeedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testInsert()
2828
->method('post')
2929
->with(
3030
$this->equalTo('https://spreadsheets.google.com/feeds/list/G3345eEsfsk60/od6/private/full'),
31-
$this->stringContains('<gsx:occupation>software engineer</gsx:occupation>')
31+
$this->stringContains('<gsx:occupation><![CDATA[software engineer]]></gsx:occupation>')
3232
);
3333

3434
ServiceRequestFactory::setInstance($mockServiceRequest);

0 commit comments

Comments
 (0)