Skip to content

Commit 18e5a0d

Browse files
committed
完成相关测试用例编写
1 parent 8e0c276 commit 18e5a0d

File tree

5 files changed

+131
-38
lines changed

5 files changed

+131
-38
lines changed

src/Mgmt/UserActionManagementClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,10 @@ public function list(array $params = [
3636
$data = $this->client->httpGet("/api/v2/analysis/user-action?$qstr");
3737
return $data;
3838
}
39+
40+
public function export()
41+
{
42+
# code...
43+
}
3944
}
4045

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
use Authing\Mgmt\GroupsManagementClient;
54
use Authing\Mgmt\ManagementClient;
65
use PHPUnit\Framework\TestCase;
@@ -10,60 +9,71 @@ class GroupsManagementClientTest extends TestCase
109
/**
1110
* @var GroupsManagementClient
1211
*/
13-
private $client;
12+
private $groupsManagement;
13+
14+
private $_testConfig;
1415

15-
private function randomString() {
16+
private function randomString()
17+
{
1618
return rand() . '';
1719
}
1820

1921
public function setUp(): void
2022
{
21-
$management = new ManagementClient("59f86b4832eb28071bdd9214", "4b880fff06b080f154ee48c9e689a541");
22-
$management->setHost("http://localhost:3000");
23+
$moduleName = str_replace('ClientTest', '', __CLASS__);
24+
$manageConfig = (object) TestConfig::getConfig('Management');
25+
$this->_testConfig = (object) TestConfig::getConfig($moduleName);
26+
$management = new ManagementClient($manageConfig->userPoolId, $manageConfig->userPoolSercet);
2327
$management->requestToken();
24-
$this->client = $management->groups();
28+
$this->groupsManagement = $management->groups();
2529
}
2630

27-
public function testPaginate() {
28-
$groups = $this->client->paginate();
31+
public function testPaginate()
32+
{
33+
$groups = $this->groupsManagement->paginate();
2934
$this->assertEquals(true, $groups->totalCount > 0);
3035
}
3136

32-
public function testCreate() {
37+
public function testCreate()
38+
{
3339
$code = $this->randomString();
34-
$group = $this->client->create($code, "group name");
40+
$group = $this->groupsManagement->create($code, "group name");
3541
$this->assertEquals($code, $group->code);
3642
}
3743

38-
public function testUpdate() {
44+
public function testUpdate()
45+
{
3946
$code = $this->randomString();
40-
$group = $this->client->create($code, "group name");
47+
$group = $this->groupsManagement->create($code, "group name");
4148

42-
$group = $this->client->update($group->code, "desc");
49+
$group = $this->groupsManagement->update($group->code, "desc");
4350
$this->assertEquals("desc", $group->name);
4451
}
4552

46-
public function testDetail() {
53+
public function testDetail()
54+
{
4755
$code = $this->randomString();
48-
$group = $this->client->create($code, "group name");
56+
$group = $this->groupsManagement->create($code, "group name");
4957

50-
$group = $this->client->detail($group->code);
58+
$group = $this->groupsManagement->detail($group->code);
5159
$this->assertEquals($code, $group->code);
5260
}
5361

54-
public function testDelete() {
62+
public function testDelete()
63+
{
5564
$code = $this->randomString();
56-
$group = $this->client->create($code, "group name");
65+
$group = $this->groupsManagement->create($code, "group name");
5766

58-
$message = $this->client->delete($group->code);
67+
$message = $this->groupsManagement->delete($group->code);
5968
$this->assertEquals(200, $message->code);
6069
}
6170

62-
public function testDeleteMany() {
71+
public function testDeleteMany()
72+
{
6373
$code = $this->randomString();
64-
$group = $this->client->create($code, "group name");
74+
$group = $this->groupsManagement->create($code, "group name");
6575

66-
$message = $this->client->deleteMany([$group->code]);
76+
$message = $this->groupsManagement->deleteMany([$group->code]);
6777
$this->assertEquals(200, $message->code);
6878
}
69-
}
79+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Authing\Mgmt\ManagementClient;
4+
use Authing\Mgmt\UserActionManagementClient;
5+
use Authing\Types\UDFDataType;
6+
use Authing\Types\UDFTargetType;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class UserActionManagementClientTest extends TestCase
10+
{
11+
/**
12+
* @var UserActionManagementClient
13+
*/
14+
private $userActionManagement;
15+
private $_testConfig;
16+
17+
public function setUp(): void
18+
{
19+
$moduleName = str_replace('ClientTest', '', __CLASS__);
20+
$manageConfig = (object) TestConfig::getConfig('Management');
21+
$this->_testConfig = (object) TestConfig::getConfig($moduleName);
22+
$management = new ManagementClient($manageConfig->userPoolId, $manageConfig->userPoolSercet);
23+
$management->requestToken();
24+
$this->userActionManagement = $management->userActions();
25+
}
26+
27+
public function testExport()
28+
{
29+
// $data = $this->userActionManagement->expo
30+
}
31+
32+
public function testList()
33+
{
34+
$data = $this->userActionManagement->list();
35+
parent::assertNotEmpty($data);
36+
}
37+
}
Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
use Authing\Mgmt\ManagementClient;
54
use Authing\Mgmt\UsersManagementClient;
65
use Authing\Types\CreateUserInput;
@@ -13,32 +12,39 @@ class UsersManagementClientTest extends TestCase
1312
* @var UsersManagementClient
1413
*/
1514
private $client;
15+
private $_testConfig;
1616

17-
private function randomString() {
17+
private function randomString()
18+
{
1819
return rand() . '';
1920
}
2021

2122
public function setUp(): void
2223
{
23-
$management = new ManagementClient("59f86b4832eb28071bdd9214", "4b880fff06b080f154ee48c9e689a541");
24-
$management->setHost("http://localhost:3000");
24+
$moduleName = str_replace('ClientTest', '', __CLASS__);
25+
$manageConfig = (object) TestConfig::getConfig('Management');
26+
$this->_testConfig = (object) TestConfig::getConfig($moduleName);
27+
$management = new ManagementClient($manageConfig->userPoolId, $manageConfig->userPoolSercet);
2528
$management->requestToken();
2629
$this->client = $management->users();
2730
}
2831

29-
public function testPaginate() {
32+
public function testPaginate()
33+
{
3034
$users = $this->client->paginate();
3135
$this->assertEquals(true, $users->totalCount > 0);
3236
}
3337

34-
public function testCreate() {
38+
public function testCreate()
39+
{
3540
$email = $this->randomString() . '@gmail.com';
3641
$password = '123456';
3742
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
3843
$this->assertEquals($email, $user->email);
3944
}
4045

41-
public function testUpdate() {
46+
public function testUpdate()
47+
{
4248
$email = $this->randomString() . '@gmail.com';
4349
$password = '123456';
4450
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -47,7 +53,8 @@ public function testUpdate() {
4753
$this->assertEquals("nickname", $user->nickname);
4854
}
4955

50-
public function testDetail() {
56+
public function testDetail()
57+
{
5158
$email = $this->randomString() . '@gmail.com';
5259
$password = '123456';
5360
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -56,7 +63,8 @@ public function testDetail() {
5663
$this->assertEquals($email, $user->email);
5764
}
5865

59-
public function testDelete() {
66+
public function testDelete()
67+
{
6068
$email = $this->randomString() . '@gmail.com';
6169
$password = '123456';
6270
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -65,7 +73,8 @@ public function testDelete() {
6573
$this->assertEquals(200, $message->code);
6674
}
6775

68-
public function testDeleteMany() {
76+
public function testDeleteMany()
77+
{
6978
$email = $this->randomString() . '@gmail.com';
7079
$password = '123456';
7180
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -74,7 +83,8 @@ public function testDeleteMany() {
7483
$this->assertEquals(200, $message->code);
7584
}
7685

77-
public function testRefreshToken() {
86+
public function testRefreshToken()
87+
{
7888
$email = $this->randomString() . '@gmail.com';
7989
$password = '123456';
8090
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -83,7 +93,8 @@ public function testRefreshToken() {
8393
$this->assertNotEquals(null, $message->token);
8494
}
8595

86-
public function testCheckLoginStatus() {
96+
public function testCheckLoginStatus()
97+
{
8798
$email = $this->randomString() . '@gmail.com';
8899
$password = '123456';
89100
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -92,7 +103,8 @@ public function testCheckLoginStatus() {
92103
$this->assertEquals(200, $message->code);
93104
}
94105

95-
public function testListRoles() {
106+
public function testListRoles()
107+
{
96108
$email = $this->randomString() . '@gmail.com';
97109
$password = '123456';
98110
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
@@ -101,12 +113,41 @@ public function testListRoles() {
101113
$this->assertEquals(true, $roles->totalCount == 0);
102114
}
103115

104-
public function testListPolicies() {
116+
public function testListPolicies()
117+
{
105118
$email = $this->randomString() . '@gmail.com';
106119
$password = '123456';
107120
$user = $this->client->create((new CreateUserInput())->withEmail($email)->withPassword($password));
108121

109122
$policies = $this->client->listPolicies($user->id);
110123
$this->assertEquals(true, $policies->totalCount == 0);
111124
}
112-
}
125+
126+
public function testGetUdfValue()
127+
{
128+
$userId = $this->_testConfig->userId;
129+
$data = $this->client->getUdfValue($userId);
130+
parent::assertNotEmpty($data);
131+
}
132+
133+
public function testListArchivedUsers()
134+
{
135+
$data = $this->client->listArchivedUsers();
136+
parent::assertNotEmpty($data);
137+
}
138+
139+
public function testListDepartment()
140+
{
141+
$userId = $this->_testConfig->userId;
142+
$data = $this->client->listDepartment($userId);
143+
parent::assertNotEmpty($data);
144+
}
145+
146+
public function testSetUdvBatch()
147+
{
148+
$data = $this->client->setUdfValueBatch();
149+
parent::assertNotEmpty($data);
150+
}
151+
152+
153+
}

0 commit comments

Comments
 (0)