Skip to content

Commit a20d0a2

Browse files
committed
Adapt tests
1 parent 3423c8e commit a20d0a2

File tree

1 file changed

+1
-48
lines changed

1 file changed

+1
-48
lines changed

tests/Unit/AI_Authorization/Infrastructure/Code_Generator/Generate_Test.php

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,6 @@ public function test_generate_with_defaults() {
3434
$this->assertSame( 64, \strlen( $result ) ); // SHA256 produces 64 character hex string.
3535
}
3636

37-
/**
38-
* Tests the generate method with custom algorithm.
39-
*
40-
* @return void
41-
*/
42-
public function test_generate_with_custom_algorithm() {
43-
$user_email = '[email protected]';
44-
$random_password = 'abcd1234ef';
45-
$algorithm = 'md5';
46-
47-
Monkey\Functions\when( 'wp_generate_password' )
48-
->justReturn( $random_password );
49-
50-
$result = $this->instance->generate( $user_email, $algorithm );
51-
52-
$expected = \hash( $algorithm, $user_email . $random_password );
53-
54-
$this->assertIsString( $result );
55-
$this->assertSame( $expected, $result );
56-
$this->assertSame( 32, \strlen( $result ) ); // MD5 produces 32 character hex string.
57-
}
58-
5937
/**
6038
* Tests the generate method with custom length.
6139
*
@@ -71,39 +49,14 @@ public function test_generate_with_custom_length() {
7149
->with( $length, false )
7250
->andReturn( $random_password );
7351

74-
$result = $this->instance->generate( $user_email, 'sha256', $length );
52+
$result = $this->instance->generate( $user_email, $length );
7553

7654
$expected = \hash( 'sha256', $user_email . $random_password );
7755

7856
$this->assertIsString( $result );
7957
$this->assertSame( $expected, $result );
8058
}
8159

82-
/**
83-
* Tests the generate method with all custom parameters.
84-
*
85-
* @return void
86-
*/
87-
public function test_generate_with_all_custom_parameters() {
88-
$user_email = '[email protected]';
89-
$algorithm = 'sha1';
90-
$length = 20;
91-
$random_password = 'customrandompassword';
92-
93-
Monkey\Functions\expect( 'wp_generate_password' )
94-
->once()
95-
->with( $length, false )
96-
->andReturn( $random_password );
97-
98-
$result = $this->instance->generate( $user_email, $algorithm, $length );
99-
100-
$expected = \hash( $algorithm, $user_email . $random_password );
101-
102-
$this->assertIsString( $result );
103-
$this->assertSame( $expected, $result );
104-
$this->assertSame( 40, \strlen( $result ) ); // SHA1 produces 40 character hex string.
105-
}
106-
10760
/**
10861
* Tests that different user emails produce different codes.
10962
*

0 commit comments

Comments
 (0)