| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class TestDocHooks |
| 4 |
* |
| 5 |
* @package micropackage/requirements |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Micropackage\Requirements\Test\Checker; |
| 9 |
|
| 10 |
use Micropackage\Requirements\Requirements; |
| 11 |
use Micropackage\Requirements\Checker\SSL as TestedChecker; |
| 12 |
|
| 13 |
/** |
| 14 |
* SSL checker test case. |
| 15 |
*/ |
| 16 |
class TestSSL extends \WP_UnitTestCase { |
| 17 |
|
| 18 |
public function setUp() { |
| 19 |
parent::setUp(); |
| 20 |
$this->checker = new TestedChecker(); |
| 21 |
} |
| 22 |
|
| 23 |
public function bad_params() { |
| 24 |
return [ |
| 25 |
[ '5.3' ], |
| 26 |
[ 1 ], |
| 27 |
[ [ true ] ], |
| 28 |
]; |
| 29 |
} |
| 30 |
|
| 31 |
public function test_get_name_should_return_valid_name() { |
| 32 |
$this->assertSame( 'ssl', $this->checker->get_name() ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* @dataProvider bad_params |
| 37 |
* @expectedException Exception |
| 38 |
*/ |
| 39 |
public function test_check_should_throw_exception_if_passed_not_bool_requirement( $param ) { |
| 40 |
$this->checker->check( $param ); |
| 41 |
} |
| 42 |
|
| 43 |
public function test_check_should_pass_when_enabled_with_ssl() { |
| 44 |
// Override server data. |
| 45 |
$_SERVER['HTTPS'] = '1'; |
| 46 |
$_SERVER['SERVER_PORT'] = '443'; |
| 47 |
|
| 48 |
$this->checker->check( true ); |
| 49 |
|
| 50 |
$this->assertEmpty( $this->checker->get_errors() ); |
| 51 |
} |
| 52 |
|
| 53 |
public function test_check_should_pass_when_disabled_without_ssl() { |
| 54 |
// Override server data. |
| 55 |
$_SERVER['HTTPS'] = '0'; |
| 56 |
$_SERVER['SERVER_PORT'] = '80'; |
| 57 |
|
| 58 |
$this->checker->check( false ); |
| 59 |
|
| 60 |
$this->assertEmpty( $this->checker->get_errors() ); |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|