|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com) |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under The MIT License |
|
6
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com) |
|
9
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace CakeDC\Api\Test\Fixture; |
|
13
|
|
|
|
|
14
|
|
|
use Cake\Auth\PasswordHasherFactory; |
|
15
|
|
|
use Cake\TestSuite\Fixture\TestFixture; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* UsersFixture |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
class UsersFixture extends TestFixture |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Fields |
|
26
|
|
|
* |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
// @codingStandardsIgnoreStart |
|
30
|
|
|
public $fields = [ |
|
31
|
|
|
'id' => ['type' => 'uuid', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], |
|
32
|
|
|
'username' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
33
|
|
|
'email' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
34
|
|
|
'password' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
35
|
|
|
'first_name' => ['type' => 'string', 'length' => 50, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
36
|
|
|
'last_name' => ['type' => 'string', 'length' => 50, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
37
|
|
|
'token' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
38
|
|
|
'token_expires' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null], |
|
39
|
|
|
'api_token' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'fixed' => null], |
|
40
|
|
|
'activation_date' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null], |
|
41
|
|
|
'tos_date' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null], |
|
42
|
|
|
'active' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => true, 'comment' => '', 'precision' => null], |
|
43
|
|
|
'is_superuser' => ['type' => 'boolean', 'length' => null, 'unsigned' => false, 'null' => false, 'default' => false, 'comment' => '', 'precision' => null, 'autoIncrement' => null], |
|
44
|
|
|
'role' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => 'user', 'comment' => '', 'precision' => null, 'fixed' => null], |
|
45
|
|
|
'created' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], |
|
46
|
|
|
'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], |
|
47
|
|
|
'_constraints' => [ |
|
48
|
|
|
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], |
|
49
|
|
|
], |
|
50
|
|
|
'_options' => [ |
|
51
|
|
|
'engine' => 'InnoDB', |
|
52
|
|
|
'collation' => 'utf8_general_ci' |
|
53
|
|
|
], |
|
54
|
|
|
]; |
|
55
|
|
|
// @codingStandardsIgnoreEnd |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Records |
|
59
|
|
|
* |
|
60
|
|
|
* @var array |
|
61
|
|
|
*/ |
|
62
|
|
|
public $records = [ |
|
63
|
|
|
[ |
|
64
|
|
|
'id' => '00000000-0000-0000-0000-000000000001', |
|
65
|
|
|
'username' => 'user-1', |
|
66
|
|
|
'email' => '[email protected]', |
|
67
|
|
|
'password' => '12345', |
|
68
|
|
|
'first_name' => 'first1', |
|
69
|
|
|
'last_name' => 'last1', |
|
70
|
|
|
'token' => 'ae93ddbe32664ce7927cf0c5c5a5e59d', |
|
71
|
|
|
'token_expires' => '2035-06-24 17:33:54', |
|
72
|
|
|
'api_token' => 'yyy', |
|
73
|
|
|
'activation_date' => '2015-06-24 17:33:54', |
|
74
|
|
|
'tos_date' => '2015-06-24 17:33:54', |
|
75
|
|
|
'active' => true, |
|
76
|
|
|
'is_superuser' => true, |
|
77
|
|
|
'role' => 'admin', |
|
78
|
|
|
'created' => '2015-06-24 17:33:54', |
|
79
|
|
|
'modified' => '2015-06-24 17:33:54' |
|
80
|
|
|
], |
|
81
|
|
|
[ |
|
82
|
|
|
'id' => '00000000-0000-0000-0000-000000000002', |
|
83
|
|
|
'username' => 'user-2', |
|
84
|
|
|
'email' => '[email protected]', |
|
85
|
|
|
'password' => '12345', |
|
86
|
|
|
'first_name' => 'user', |
|
87
|
|
|
'last_name' => 'second', |
|
88
|
|
|
'token' => '6614f65816754310a5f0553436dd89e9', |
|
89
|
|
|
'token_expires' => '2015-06-24 17:33:54', |
|
90
|
|
|
'api_token' => 'xxx', |
|
91
|
|
|
'activation_date' => '2015-06-24 17:33:54', |
|
92
|
|
|
'tos_date' => '2015-06-24 17:33:54', |
|
93
|
|
|
'active' => true, |
|
94
|
|
|
'is_superuser' => false, |
|
95
|
|
|
'role' => 'admin', |
|
96
|
|
|
'created' => '2015-06-24 17:33:54', |
|
97
|
|
|
'modified' => '2015-06-24 17:33:54' |
|
98
|
|
|
], |
|
99
|
|
|
[ |
|
100
|
|
|
'id' => '00000000-0000-0000-0000-000000000004', |
|
101
|
|
|
'username' => 'user-4', |
|
102
|
|
|
'email' => '[email protected]', |
|
103
|
|
|
'password' => 'Lorem ipsum dolor sit amet', |
|
104
|
|
|
'first_name' => 'FirstName4', |
|
105
|
|
|
'last_name' => 'Lorem ipsum dolor sit amet', |
|
106
|
|
|
'token' => 'token-4', |
|
107
|
|
|
'token_expires' => '2030-06-24 17:33:54', |
|
108
|
|
|
'api_token' => 'zzz', |
|
109
|
|
|
'activation_date' => '2015-06-24 17:33:54', |
|
110
|
|
|
'tos_date' => '2015-06-24 17:33:54', |
|
111
|
|
|
'active' => true, |
|
112
|
|
|
'is_superuser' => false, |
|
113
|
|
|
'role' => 'Lorem ipsum dolor sit amet', |
|
114
|
|
|
'created' => '2015-06-24 17:33:54', |
|
115
|
|
|
'modified' => '2015-06-24 17:33:54' |
|
116
|
|
|
], |
|
117
|
|
|
[ |
|
118
|
|
|
'id' => '00000000-0000-0000-0000-000000000005', |
|
119
|
|
|
'username' => 'user-5', |
|
120
|
|
|
'email' => '[email protected]', |
|
121
|
|
|
'password' => '12345', |
|
122
|
|
|
'first_name' => 'first-user-5', |
|
123
|
|
|
'last_name' => 'firts name 5', |
|
124
|
|
|
'token' => 'token-5', |
|
125
|
|
|
'token_expires' => '2015-06-24 17:33:54', |
|
126
|
|
|
'api_token' => '', |
|
127
|
|
|
'activation_date' => '2015-06-24 17:33:54', |
|
128
|
|
|
'tos_date' => '2015-06-24 17:33:54', |
|
129
|
|
|
'active' => true, |
|
130
|
|
|
'is_superuser' => false, |
|
131
|
|
|
'role' => 'user', |
|
132
|
|
|
'created' => '2015-06-24 17:33:54', |
|
133
|
|
|
'modified' => '2015-06-24 17:33:54' |
|
134
|
|
|
], |
|
135
|
|
|
[ |
|
136
|
|
|
'id' => '00000000-0000-0000-0000-000000000006', |
|
137
|
|
|
'username' => 'user-6', |
|
138
|
|
|
'email' => '[email protected]', |
|
139
|
|
|
'password' => '12345', |
|
140
|
|
|
'first_name' => 'first-user-6', |
|
141
|
|
|
'last_name' => 'last name 6', |
|
142
|
|
|
'token' => 'token-6', |
|
143
|
|
|
'token_expires' => '2030-06-24 17:33:54', |
|
144
|
|
|
'api_token' => '', |
|
145
|
|
|
'activation_date' => null, |
|
146
|
|
|
'tos_date' => '2015-06-24 17:33:54', |
|
147
|
|
|
'active' => false, |
|
148
|
|
|
'is_superuser' => false, |
|
149
|
|
|
'role' => 'user', |
|
150
|
|
|
'created' => '2015-06-24 17:33:54', |
|
151
|
|
|
'modified' => '2015-06-24 17:33:54' |
|
152
|
|
|
], |
|
153
|
|
|
]; |
|
154
|
|
|
|
|
155
|
|
|
public function __construct() |
|
156
|
|
|
{ |
|
157
|
|
|
$hasher = PasswordHasherFactory::build('\Cake\Auth\DefaultPasswordHasher'); |
|
158
|
|
|
parent::__construct(); |
|
159
|
|
|
foreach ($this->records as &$record) { |
|
160
|
|
|
$record['password'] = $hasher->hash($record['password']); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|