-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGetGroupByIdTest.php
More file actions
85 lines (79 loc) · 1.89 KB
/
GetGroupByIdTest.php
File metadata and controls
85 lines (79 loc) · 1.89 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
<?php
/**
* Group::getGroupById()のテスト
*
* @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::getGroupById()のテスト
*
* @author Yuna Miyashita <butackle@gmail.com>
* @package NetCommons\Groups\Test\Case\Model\Group
*/
class GroupGetGroupByIdTest 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);
}
/**
* getGroupById()のテスト
*
* @dataProvider dataProviderGetGroupById
* @param $groupId
* @return void
*/
public function testGetGroupById($groupId = 1) {
$actualGroups = $this->_classGroup->getGroupById($groupId);
//返り値が空の時の確認
if (!in_array($groupId, [1, 2])) {
$this->assertEquals(
array('GroupsUsersDetail' => []),
$actualGroups,
'想定と違う値が返っています'
);
return;
}
//ユーザ情報確認
$this->_assertGroupsUsersDetail($groupId, $actualGroups['GroupsUsersDetail']);
//グループ情報確認
unset($actualGroups['GroupsUsersDetail']);
$this->assertEquals(
$this->_group->findById($groupId),
$actualGroups,
'想定と違う値が返っています'
);
}
/**
* testGetGroupById用dataProvider
*
* ### 戻り値
* - id: グループID
*/
public function dataProviderGetGroupById() {
return array(
[''],
[1],
[2],
[999]
);
}
}