-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetUserAttributesRoleTest.php
More file actions
130 lines (115 loc) · 2.94 KB
/
GetUserAttributesRoleTest.php
File metadata and controls
130 lines (115 loc) · 2.94 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* UserAttributesRole::getUserAttributesRole()のテスト
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@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('NetCommonsGetTest', 'NetCommons.TestSuite');
/**
* UserAttributesRole::getUserAttributesRole()のテスト
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\UserRoles\Test\Case\Model\UserAttributesRole
*/
class UserAttributesRoleGetUserAttributesRoleTest extends NetCommonsGetTest {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'plugin.user_roles.user_attributes_role4edit',
'plugin.user_roles.user_role_setting',
);
/**
* Plugin name
*
* @var string
*/
public $plugin = 'user_roles';
/**
* Model name
*
* @var string
*/
protected $_modelName = 'UserAttributesRole';
/**
* Method name
*
* @var string
*/
protected $_methodName = 'getUserAttributesRole';
/**
* getUserAttributesRole()のテスト
*
* @return void
*/
public function testGetUserAttributesRole() {
//データ生成
$roleKey = 'common_user';
//期待値のデータ生成
$id1 = '7';
$id2 = '8';
$id3 = '9';
$actual = array(
$id1 => array('UserAttributesRole' => array(
'id' => $id1,
'role_key' => $roleKey,
'user_attribute_key' => 'user_attribute_key',
'self_readable' => true,
'self_editable' => true,
'other_readable' => false,
'other_editable' => false,
)),
$id2 => array('UserAttributesRole' => array(
'id' => $id2,
'role_key' => $roleKey,
'user_attribute_key' => 'radio_attribute_key',
'self_readable' => true,
'self_editable' => false,
'other_readable' => false,
'other_editable' => false,
)),
$id3 => array('UserAttributesRole' => array(
'id' => $id3,
'role_key' => $roleKey,
'user_attribute_key' => 'system_attribute_key',
'self_readable' => false,
'self_editable' => false,
'other_readable' => false,
'other_editable' => false,
)),
);
//テスト実施
$model = $this->_modelName;
$methodName = $this->_methodName;
$result = $this->$model->$methodName($roleKey);
$result = Hash::remove($result, '{n}.{s}.created');
$result = Hash::remove($result, '{n}.{s}.created_user');
$result = Hash::remove($result, '{n}.{s}.modified');
$result = Hash::remove($result, '{n}.{s}.modified_user');
//チェック
$this->assertEquals($actual, $result);
}
/**
* getUserAttributesRole()のテスト
*
* @return void
*/
public function testGetUserAttributesRoleByNotKey() {
//データ生成
$roleKey = 'aaaaaa';
//期待値のデータ生成
$actual = array();
//テスト実施
$model = $this->_modelName;
$methodName = $this->_methodName;
$result = $this->$model->$methodName($roleKey);
//チェック
$this->assertEquals($actual, $result);
}
}