-
Notifications
You must be signed in to change notification settings - Fork 6
/
testPlurk.php
121 lines (108 loc) · 3.42 KB
/
testPlurk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?
require('plurkAPI.php');
class PlurkAPITest extends PHPUnit_Framework_TestCase {
protected $consumer_key;
protected $consumer_secret;
protected $oauth_token;
protected $oauth_token_secret;
protected $plurk;
public function setUp(){
$this->consumer_key = CONSUMER_KEY;
$this->consumer_secret = CONSUMER_SECRET;
$this->oauth_token = ACCESS_TOKEN;
$this->oauth_token_secret = ACCESS_TOKEN_SECRET;
}
public function tearDown(){}
/**
* @expectedException InvalidArgumentException
*/
public function testNoConsumerKey()
{
$plurk = new PlurkAPI();
}
public function testInvalidConsumerKey()
{
$plurk = new PlurkAPI("abc", "def");
$json = $plurk->callAPI('/APP/Profile/getPublicProfile',
array('user_id' => 'clsung'), true);
$this->assertNull($json);
$this->assertContains('40101:unknown application key', $plurk->error());
}
public function testValidConsumerKey()
{
$plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret);
$json = $plurk->callAPI('/APP/Profile/getPublicProfile', array('user_id' => 'clsung'), true);
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
}
/**
* @depends testValidConsumerKey
*/
public function testcurrUser()
{
$plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret,
$this->oauth_token, $this->oauth_token_secret
);
$json = $plurk->callAPI('/APP/Users/currUser');
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
}
/**
* @depends testValidConsumerKey
*/
public function testGetOwnProfile()
{
$plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret,
$this->oauth_token, $this->oauth_token_secret
);
$json = $plurk->callAPI('/APP/Profile/getOwnProfile');
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
}
/**
* @depends testValidConsumerKey
*/
public function testGetAccessToken()
{
$this->markTestIncomplete("Only when you need to get access token");
$oauth = new PlurkOAuth($this->consumer_key, $this->consumer_secret);
$this->assertTrue($oauth->authorize());
}
/**
* @depends testValidConsumerKey
*/
public function testAPIplurkAdd()
{
$plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret,
$this->oauth_token, $this->oauth_token_secret
);
$json = $plurk->callAPI('/APP/Timeline/plurkAdd',
array ('content' => 'Post by plurkoauth which based on php', 'qualifier' => 'hates')
);
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
}
/**
* @depends testValidConsumerKey
*/
public function testAPIresponseAdd()
{
$plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret,
$this->oauth_token, $this->oauth_token_secret
);
# reply to http://www.plurk.com/p/cs770l
$plurk_id = base_convert("cs770l",36,10);
$json = $plurk->callAPI('/APP/Responses/responseAdd',
array ('plurk_id' => $plurk_id,
'content' => 'Response test by plurkoauth', 'qualifier' => 'says')
);
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
$json = $plurk->callAPI('/APP/Responses/responseAdd',
array ('plurk_id' => $plurk_id,
'content' => 'plurkoauth is https://github.com/clsung/plurkoauth (here)', 'qualifier' => 'shares')
);
$this->assertNotNull($json);
$this->assertEquals(0, $plurk->errno());
}
}