-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtest-hideadmin.php
58 lines (49 loc) · 1.54 KB
/
test-hideadmin.php
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
<?php
class LockdownAdminTest extends PHPUnit_Framework_TestCase {
protected $object;
protected function setUp()
{
$this->object = ld_setup_auth();
}
public function testWhitelist()
{
add_filter('no_check_files', function($a) { $a[] = 'wp-activate.php'; return $a; });
$this->object->application->setHideWpAdmin( true );
// Mocking a request to wp-activate.php
$_SERVER['SCRIPT_FILENAME'] = ABSPATH.'/wp-activate.php';
// Set it back up again so we can test if it passed
$this->setUp();
$this->assertTrue( $this->object->getAuthPassed() );
remove_all_filters( 'no_check_files' );
}
public function testWhitelistToBlock()
{
$this->object->application->setHideWpAdmin( true );
// Mocking a request to wp-activate.php
$_SERVER['SCRIPT_FILENAME'] = ABSPATH.'/wp-login.php';
// Set it back up again so we can test if it passed
$this->setUp();
$this->assertFalse( $this->object->getAuthPassed() );
}
//
// public function testConceal() {
// global $current_screen;
// $this->assertFalse( is_admin() );
// $screen = WP_Screen::get( 'admin_init' );
// $current_screen = $screen;
//
// $this->object->application->setHideWpAdmin( true );
// $this->assertTrue( is_admin() );
//
// // Add action to get called
// $mock = $this->getMock('stdClass', array( 'onInvalidAccess' ));
// $mock->expects($this->once())
// ->method( 'onInvalidAccess' )
// ->will( $this->returnValue( true ) );
//
// $app = new Lockdown_Application( $this->object );
//
// // Reset current screen
// $current_screen = null;
// }
}