Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
de230fd3
Commit
de230fd3
authored
Sep 24, 2013
by
Petr Škoda
Browse files
MDL-37324 fix phpunit and behat SESSION and USER setup
parent
c925e4fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/classes/session/manager.php
View file @
de230fd3
...
@@ -155,8 +155,9 @@ class manager {
...
@@ -155,8 +155,9 @@ class manager {
$_SESSION
[
'USER'
]
->
mnethostid
=
1
;
$_SESSION
[
'USER'
]
->
mnethostid
=
1
;
}
}
if
(
PHPUNIT_TEST
)
{
if
(
PHPUNIT_TEST
or
defined
(
'BEHAT_TEST'
))
{
// Phpunit tests use reversed reference.
// Phpunit tests and behat init use reversed reference,
// the reason is we can not point global to $_SESSION outside of global scope.
global
$USER
,
$SESSION
;
global
$USER
,
$SESSION
;
$USER
=
$_SESSION
[
'USER'
];
$USER
=
$_SESSION
[
'USER'
];
$SESSION
=
$_SESSION
[
'SESSION'
];
$SESSION
=
$_SESSION
[
'SESSION'
];
...
@@ -597,8 +598,9 @@ class manager {
...
@@ -597,8 +598,9 @@ class manager {
}
}
sesskey
();
// Init session key.
sesskey
();
// Init session key.
if
(
PHPUNIT_TEST
)
{
if
(
PHPUNIT_TEST
or
defined
(
'BEHAT_TEST'
))
{
// Phpunit tests use reversed reference.
// Phpunit tests and behat init use reversed reference,
// the reason is we can not point global to $_SESSION outside of global scope.
global
$USER
;
global
$USER
;
$USER
=
$_SESSION
[
'USER'
];
$USER
=
$_SESSION
[
'USER'
];
$_SESSION
[
'USER'
]
=&
$USER
;
$_SESSION
[
'USER'
]
=&
$USER
;
...
...
lib/setup.php
View file @
de230fd3
...
@@ -765,8 +765,10 @@ if (empty($CFG->sessiontimeout)) {
...
@@ -765,8 +765,10 @@ if (empty($CFG->sessiontimeout)) {
$CFG
->
sessiontimeout
=
7200
;
$CFG
->
sessiontimeout
=
7200
;
}
}
\
core\session\manager
::
start
();
\
core\session\manager
::
start
();
$SESSION
=
&
$_SESSION
[
'SESSION'
];
if
(
!
PHPUNIT_TEST
and
!
defined
(
'BEHAT_TEST'
))
{
$USER
=
&
$_SESSION
[
'USER'
];
$SESSION
=&
$_SESSION
[
'SESSION'
];
$USER
=&
$_SESSION
[
'USER'
];
}
// Late profiling, only happening if early one wasn't started
// Late profiling, only happening if early one wasn't started
if
(
!
empty
(
$CFG
->
profilingenabled
))
{
if
(
!
empty
(
$CFG
->
profilingenabled
))
{
...
...
lib/tests/behat/behat_hooks.php
View file @
de230fd3
...
@@ -162,8 +162,10 @@ class behat_hooks extends behat_base {
...
@@ -162,8 +162,10 @@ class behat_hooks extends behat_base {
behat_selectors
::
register_moodle_selectors
(
$session
);
behat_selectors
::
register_moodle_selectors
(
$session
);
}
}
// Avoid some notices / warnings.
// Reset $SESSION.
$_SESSION
=
array
();
$SESSION
=
new
stdClass
();
$SESSION
=
new
stdClass
();
$_SESSION
[
'SESSION'
]
=&
$SESSION
;
behat_util
::
reset_database
();
behat_util
::
reset_database
();
behat_util
::
reset_dataroot
();
behat_util
::
reset_dataroot
();
...
@@ -174,7 +176,7 @@ class behat_hooks extends behat_base {
...
@@ -174,7 +176,7 @@ class behat_hooks extends behat_base {
// Reset the nasty strings list used during the last test.
// Reset the nasty strings list used during the last test.
nasty_strings
::
reset_used_strings
();
nasty_strings
::
reset_used_strings
();
// Assi
n
g valid data to admin user (some generator-related code needs a valid user).
// Assig
n
valid data to admin user (some generator-related code needs a valid user).
$user
=
$DB
->
get_record
(
'user'
,
array
(
'username'
=>
'admin'
));
$user
=
$DB
->
get_record
(
'user'
,
array
(
'username'
=>
'admin'
));
\
core\session\manager
::
set_user
(
$user
);
\
core\session\manager
::
set_user
(
$user
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment