-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGetGroupUserTest.php
More file actions
87 lines (81 loc) · 1.9 KB
/
GetGroupUserTest.php
File metadata and controls
87 lines (81 loc) · 1.9 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
<?php
/**
* Group::getGroupUser()のテスト
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Yuna Miyashita <butackle@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('GroupsModelTestBase', 'Groups.Test/Case');
/**
* Group::getGroupUser()のテスト
*
* @author Yuna Miyashita <butackle@gmail.com>
* @package NetCommons\Groups\Test\Case\Model\Group
*/
class GroupGetGroupUserTest extends GroupsModelTestBase {
/**
* Fixtures Setting
*
* @param string $name
* @param array $data
* @param string $dataName
* @var array
*/
public function __construct($name = null, array $data = array(), $dataName = '') {
$this->fixtures = array_merge(
$this->fixtures,
[
'plugin.groups.group4_users_test',
'plugin.groups.groups_user4_users_test'
]
);
parent::__construct($name, $data, $dataName);
}
/**
* getGroupUser()のテスト
*
* @dataProvider dataProviderGroupUser
* @param int|array $groupIds
* @return void
*/
public function testGetGroupUser($groupIds = [1, 2]) {
$actualGroupUser = $this->_classGroup->getGroupUser($groupIds);
if (!is_array($groupIds)) {
$this->_assertGroupsUsersDetail(
$groupIds, $actualGroupUser
);
return;
}
$expectedUserIds = $this->_getExpectedUserIds([implode(',', $groupIds)]);
$this->assertCount(
count($expectedUserIds),
$actualGroupUser
);
foreach ($expectedUserIds as $index => $userId) {
$this->assertEquals(
$this->controller->User->findById($userId)['User'],
$actualGroupUser[$index]['User'],
'想定と違う値が返っています'
);
}
}
/**
* testGetGroupUser用dataProvider
*
* ### 戻り値
* - id: グループID
*/
public function dataProviderGroupUser() {
return array(
[null],
[],
[1],
[2],
[[1, 2]],
[[1, 9999]],
);
}
}