forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpAuthCheck.php
More file actions
64 lines (53 loc) · 1.26 KB
/
wpAuthCheck.php
File metadata and controls
64 lines (53 loc) · 1.26 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
<?php
/**
* @group functions.php
*
* Tests for the behavior of `wp_auth_check()`
*/
class Tests_Functions_WP_Auth_Check extends WP_UnitTestCase {
/**
* Run with user not logged in.
*
* @ticket 41860
*/
function test_wp_auth_check_user_not_logged_in() {
$expected = array(
'wp-auth-check' => false,
);
$this->assertFalse( is_user_logged_in() );
$this->assertSame( $expected, wp_auth_check( array() ) );
}
/**
* Run with user logged in.
*
* @ticket 41860
*/
function test_wp_auth_check_user_logged_in() {
// log user in
wp_set_current_user( 1 );
$expected = array(
'wp-auth-check' => true,
);
$this->assertTrue( is_user_logged_in() );
$this->assertSame( $expected, wp_auth_check( array() ) );
}
/**
* Run with user logged in but with expired state.
*
* @ticket 41860
*/
function test_wp_auth_check_user_logged_in_login_grace_period_set() {
// log user in
wp_set_current_user( 1 );
$GLOBALS['login_grace_period'] = 1;
$expected = array(
'wp-auth-check' => false,
);
$actual = wp_auth_check( array() );
$logged_in = is_user_logged_in();
// Leave the global state unchanged
unset( $GLOBALS['login_grace_period'] );
$this->assertTrue( $logged_in );
$this->assertSame( $expected, $actual );
}
}