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 |
----------------------------------------------------------
In test.php, before creating the dispatcher. (Optional, done mostly
as a convenience so I remember what the settings are later):
----------------------------------------------------------
Configure::write('UnitTest.bypassSSL', true); // bypass SSL settings
Configure::write('UnitTest.bypassAuth', true); // bypass Auth settings (auto allow())
Configure::write('UnitTest.spoofAuthUser', false); // data array to set as the Auth User
In bootstrap.php, anywhere:
----------------------------------------------------------
}
In app_controller.php:
----------------------------------------------------------
if ( !CAKE_UNIT_TEST or is_empty(Configure::read('UnitTest.bypassSSL')) ) {
$this->Security->requireSecure();
$this->Security->blackHoleCallback = '_blackHole';
}
In app_controller, after defining Auth settings.
----------------------------------------------------------
if ( CAKE_UNIT_TEST ) {
// Allow the user
if ( !is_empty(Configure::read('UnitTest.bypassAuth')) ) {
$this->Auth->allow();
}
// Spoof the user
if ( !is_empty(Configure::read('UnitTest.spoofAuthUser')) ) {
$this->Auth->Session->write($this->Auth->sessionKey, Configure::read('UnitTest.spoofAuthUser'));
}
}
|
