Repository navigation
Expand file tree
/
Copy pathUserTest.php
More file actions
94 lines (72 loc) · 2.48 KB
/
Copy pathUserTest.php
File metadata and controls
94 lines (72 loc) · 2.48 KB
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
<?php
require_once('NingApi.php');
require_once('TestConfig.php');
class UserTest extends PHPUnit_Framework_TestCase {
protected $ningApi;
protected function setUp() {
$subdomain = TestConfig::SUBDOMAIN;
$consumer_key = TestConfig::CONSUMER_KEY;
$consumer_secret = TestConfig::CONSUMER_SECRET;
$ningApi = new NingApi($subdomain, $consumer_key, $consumer_secret);
$this->ningApi = $ningApi;
$this->ningApi->login(TestConfig::EMAIL, TestConfig::PASSWORD);
}
public function create($n) {
$parts = array(
'email' => 'testUser'.$n.'@ning.com',
'password' => 'Test1234',
'fullName' => 'User Create Test'
);
$result = $this->ningApi->post('User', $parts);
$this->assertTrue($result['success']);
$this->userId = $result['id'];
return $result;
}
public function testCreate() {
$result = $this->create(1);
$this->assertTrue($result['success']);
}
public function testUpdate() {
$result = $this->create(2);
$parts = array(
'id' => $result['id'],
'fullName' => 'User Update Test'
);
$result = $this->ningApi->put('User', $parts);
$this->assertTrue($result['success']);
}
public function testGet() {
$result = $this->create(3);
$fields = 'email,fullName';
$path = sprintf('User/?id=%s&fields=%s', $result['id'], $fields);
$result = $this->ningApi->get($path);
$this->assertTrue($result['success']);
}
public function testRecent() {
$count = 3;
$fields = 'fullName,createdDate';
$path = sprintf('User/recent?count=%s&fields=%s', $count,
$fields);
$result = $this->ningApi->get($path);
$this->assertTrue($result['success']);
}
public function testFeatured() {
$count = 3;
$fields = 'fullName,featuredDate';
$path = sprintf('User/featured?count=%s&fields=%s', $count,
$fields);
$result = $this->ningApi->get($path);
$this->assertTrue($result['success']);
}
public function testPending() {
$count = 3;
$fields = 'fullName,createdDate';
$path = sprintf('User/pending?count=%s&fields=%s', $count,
$fields);
$result = $this->ningApi->get($path);
$this->assertTrue($result['success']);
}
protected function tearDown() {
$this->ningApi = NULL;
}
}