Completed
Push — add/password-package ( 635be6...1b9366 )
by
unknown
230:46 queued 220:53
created

Password_Checker_Test   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set_up() 0 7 2
A tear_down() 0 3 1
A test_password() 0 9 1
1
<?php
2
/**
3
 * Tests the Password_Checker package.
4
 *
5
 * @package automattic/jetpack-password-checker
6
 */
7
8
use Automattic\Jetpack\Password_Checker;
9
use Brain\Monkey;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * Test Password_Checker class
14
 */
15
class Password_Checker_Test extends TestCase {
16
17
	/**
18
	 * Sets up the test.
19
	 *
20
	 * @before
21
	 */
22
	public function set_up() {
23
		if ( ! defined( 'JETPACK__VERSION' ) ) {
24
			define( 'JETPACK__VERSION', '7.5' );
25
		}
26
		Monkey\setUp();
27
		Monkey\Functions\stubs( array( '__' => null ) );
28
	}
29
30
	/**
31
	 * Tears down the test.
32
	 *
33
	 * @after
34
	 */
35
	public function tear_down() {
36
		Monkey\tearDown();
37
	}
38
39
	/**
40
	 * Test the password checker.
41
	 */
42
	public function test_password() {
43
		$password_checker = new Password_Checker( null );
44
45
		$test_results = $password_checker->test( '123', true );
46
		$this->assertFalse( $test_results['passed'] );
47
48
		$test_results = $password_checker->test( 'password', true );
49
		$this->assertTrue( $test_results['passed'] );
50
	}
51
}
52