Skip to content

Commit

Permalink
Merge pull request #23 from michield/master
Browse files Browse the repository at this point in the history
fix utf8 issues
  • Loading branch information
michield committed Nov 24, 2015
2 parents e6e95e7 + 3ad5878 commit af41303
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@
# whitelist
language: php
php:
- 7.0
- 5.6
- 5.5
- 5.4
Expand Down
26 changes: 26 additions & 0 deletions plugins/restapi/doc/doc.php
Expand Up @@ -61,6 +61,32 @@ public function output()
public function header()
{
return '
<style type="text/css">
.param-required {
background-color: #DD5600;
}
.param-optional {
background-color: #669533;
}
.restapi-datatype {
background-color: #999;
}
.restapi-param, .restapi-datatype {
border-radius: 3px;
display: inline-block;
padding: 2px 4px;
font-size: 11.844px;
font-weight: bold;
line-height: 14px;
color: #FFF;
vertical-align: baseline;
white-space: nowrap;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.25);
}
</style>
<header class="jumbotron subhead" id="overview">
<div class="row">
Expand Down
4 changes: 2 additions & 2 deletions plugins/restapi/includes/response.php
Expand Up @@ -36,7 +36,7 @@ public function setData($type, $data)

public function output()
{
header('Content-Type: application/json');
header('Content-Type: application/json; charset=utf-8;');
echo $this->json_encode2($this->result);
die(0);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public function object_to_array($var)
}
} else {
// simple values are untouched
$result[$key] = utf8_encode($value);
$result[$key] = $value;
}
}

Expand Down
34 changes: 32 additions & 2 deletions tests/phpunit/restapi.php
Expand Up @@ -702,7 +702,37 @@ function testCreateCampaign($templateId) {
$campaignID = $result->data->id;
return $campaignID;
}


/**
*
* test creating a campaign with UTF-8 characters
*/

function testCreateCampaignUTF8() {
$post_params = array(
'subject' => 'Test Campaign created by API '.time(),
'fromfield' => 'From Name apitest@phplist.com',
'replyto' => '',
'message' => '快速的棕色狐狸跳过懒狗',
'textmessage' => '快速的棕色狐狸跳过懒狗',
'footer' => 'Footer',
'status' => 'submitted',
'sendformat' => 'both',
'template' => 0,
'embargo' => date('Y-m-d'),
'rsstemplate' => '',
'owner' => 0,
'htmlformatted' => 1,
);

$result = $this->callAPI('campaignAdd', $post_params);
$this->assertEquals('success', $result->status);
$campaignID = $result->data->id;
$this->assertEquals($result->data->message,'快速的棕色狐狸跳过懒狗');
return $campaignID;
}


/**
* update a campaign
* @depends testCreateCampaign
Expand Down Expand Up @@ -755,7 +785,7 @@ public function testCountCampaignsAgain($campaignCount)

$result = $this->callAPI('campaignsCount', $post_params);
$this->assertEquals('success', $result->status);
$this->assertEquals($campaignCount+1, $result->data->total);
$this->assertEquals($campaignCount+2, $result->data->total);
$campaignCount = $result->data->total;

return $campaignCount;
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/test-template1.html
Expand Up @@ -20,5 +20,10 @@ <h3 style="margin:10px;text-align:right;font-weight:normal; color:#FFF !importan
</tr>
</tbody>
</table>

<p>Some texts in UTF-8</p>
<p>快速的棕色狐狸跳过懒狗</p>
<p>速い茶色のキツネは、のろまなイヌに飛びかかりました</p>

</div>
</div>

0 comments on commit af41303

Please sign in to comment.