Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (52 sloc) 1.787 kb
7f4d1d4 @clsung - init plurkoauth, implement Plurk API 2 (OAuth)
authored
1 <?
2
3 require('plurkAPI.php');
4
5 class PlurkAPITest extends PHPUnit_Framework_TestCase {
6
7 protected $consumer_key;
8 protected $consumer_secret;
9 protected $oauth_token;
10 protected $oauth_token_secret;
11 protected $plurk;
12
13 public function setUp(){
14 $this->consumer_key = 'YOUR_CONSUMER_KEY';
15 $this->consumer_secret = 'YOUR_CONSUMER_SECRET';
16 $this->oauth_token = 'YOUR_ACCESS_TOKEN';
17 $this->oauth_token_secret = 'YOUR_ACCESS_TOKEN_SECRET';
18 }
19
20 public function tearDown(){}
21
22 /**
23 * @expectedException InvalidArgumentException
24 */
25 public function testNoConsumerKey()
26 {
27 $plurk = new PlurkAPI();
28 }
29
30 public function testInvalidConsumerKey()
31 {
32 $this->markTestSkipped("Due to oauth-php session incomplete, we need to skip it");
33 $plurk = new PlurkAPI("abc", "def");
34 $json = $plurk->callAPI('/APP/Profile/getPublicProfile',
35 array('user_id' => 'clsung'), true);
36 $this->assertNull($json);
37 $this->assertContains('40101:unknown application key', $plurk->error());
38 }
39
40 public function testValidConsumerKey()
41 {
42 $plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret);
43 $json = $plurk->callAPI('/APP/Profile/getPublicProfile', array('user_id' => 'clsung'), true);
44 $this->assertNotNull($json);
45 $this->assertEquals(0, $plurk->errno());
46 }
47
48 /**
49 * @depends testValidConsumerKey
50 */
51 public function testGetOwnProfile()
52 {
53 $this->markTestSkipped("Due to oauth-php session incomplete, we need to skip it");
54 $plurk = new PlurkAPI($this->consumer_key, $this->consumer_secret,
55 $this->oauth_token, $this->oauth_token_secret
56 );
57 $json = $plurk->callAPI('/APP/Profile/getOwnProfile');
58 $this->assertNotNull($json);
59 $this->assertEquals(0, $plurk->errno());
60 }
61
62 }
Something went wrong with that request. Please try again.