Skip to content

Commit b20658d

Browse files
SirLouenarnt
authored andcommitted
Adding some CS fixes
1 parent 2450987 commit b20658d

File tree

6 files changed

+76
-31
lines changed

6 files changed

+76
-31
lines changed

tests/phpunit/tests/formatting/antispambot.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
32
/**
4-
* @group formatting
3+
* Tests for the antispambot() function.
54
*
5+
* @group formatting
66
* @covers ::antispambot
77
*/
8-
class Tests_Formatting_antispambot extends WP_UnitTestCase {
8+
class Tests_Formatting_Antispambot extends WP_UnitTestCase {
99

1010
/**
1111
* This is basically a driveby test. While working on ticket
@@ -16,12 +16,16 @@ class Tests_Formatting_antispambot extends WP_UnitTestCase {
1616
* @ticket 31992
1717
*
1818
* @dataProvider data_returns_valid_utf8
19+
* @param string $address The email address to obfuscate.
20+
* @param bool $validity Whether the obfuscated address should be valid UTF-8.
1921
*/
20-
2122
public function test_returns_valid_utf8( $address, $validity ) {
2223
$this->assertSame( wp_is_valid_utf8( antispambot( $address ) ), $validity );
2324
}
2425

26+
/**
27+
* Data provider for test_returns_valid_utf8.
28+
*/
2529
public function data_returns_valid_utf8() {
2630
return array(
2731
'plain' => array( '[email protected]', true ),

tests/phpunit/tests/formatting/isEmail.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
2-
32
/**
3+
* Tests for the is_email() function.
4+
*
45
* @group formatting
56
*
67
* @covers ::is_email
78
*/
89
class Tests_Formatting_IsEmail extends WP_UnitTestCase {
10+
/**
11+
* This test checks that valid email addresses return the same address.
12+
*
13+
* @ticket 31992
14+
*/
915
public function test_returns_the_email_address_if_it_is_valid() {
1016
$data = array(
1117
@@ -25,6 +31,11 @@ public function test_returns_the_email_address_if_it_is_valid() {
2531
}
2632
}
2733

34+
/**
35+
* This test checks that invalid email addresses return false.
36+
*
37+
* @ticket 31992
38+
*/
2839
public function test_returns_false_if_given_an_invalid_email_address() {
2940
$data = array(
3041
'khaaaaaaaaaaaaaaan!',
@@ -34,16 +45,20 @@ public function test_returns_false_if_given_an_invalid_email_address() {
3445
'bob@your mom',
3546
3647
'" "@b.c',
37-
'h([email protected]', // bad comment
48+
'h([email protected]', // bad comment.
3849
'hi@',
39-
'hi@[email protected]', // double @
40-
/* The next address is not deliverable as described,
50+
'hi@[email protected]', // double @.
51+
52+
/*
53+
* The next address is not deliverable as described,
4154
* SMTP servers should strip the (ab), so it is very
4255
* likely a source of confusion or a typo.
4356
* Best rejected.
4457
*/
4558
46-
/* The next address is not globally deliverable,
59+
60+
/*
61+
* The next address is not globally deliverable,
4762
* so it may work with PHPMailer and break with
4863
* mail sending services. Best not allow users
4964
* to paint themselves into that corner. This also
@@ -52,7 +67,9 @@ public function test_returns_false_if_given_an_invalid_email_address() {
5267
* browsers and servers.
5368
*/
5469
'toto@to',
55-
/* Several addresses are best rejected because
70+
71+
/*
72+
* Several addresses are best rejected because
5673
* we don't want to allow sending to fe80::, 192.168
5774
* and other special addresses; that too might
5875
* be used to probe the Wordpress server's local
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
<?php
2-
32
/**
4-
* @group formatting
3+
* Tests for the sanitize_email() function.
54
*
5+
* @group formatting
66
* @covers ::sanitize_email
77
*/
88
class Tests_Formatting_SanitizeEmail extends WP_UnitTestCase {
9+
10+
/**
11+
* This test checks that email addresses are properly sanitized.
12+
*
13+
* @ticket 31992
14+
* @dataProvider data_for_sanitation
15+
* @param string $address The email address to sanitize.
16+
* @param string $expected The expected sanitized email address.
17+
*/
18+
public function test_returns_stripped_email_address( $address, $expected ) {
19+
$this->assertSame( sanitize_email( $address ), $expected );
20+
}
21+
22+
/**
23+
* Data provider for test_returns_stripped_email_address.
24+
*/
925
public function data_for_sanitation() {
1026
return array(
1127
'shorter than 6 characters' => array( 'a@b', '' ),
@@ -14,13 +30,4 @@ public function data_for_sanitation() {
1430
'plain' => array( '[email protected]', '[email protected]' ),
1531
);
1632
}
17-
18-
/**
19-
* @ticket 31992
20-
* @dataProvider data_for_sanitation
21-
*/
22-
23-
public function test_returns_stripped_email_address( $address, $expected ) {
24-
$this->assertSame( sanitize_email( $address ), $expected );
25-
}
2633
}

tests/phpunit/tests/formatting/sanitizeTitle.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3+
use SebastianBergmann\RecursionContext\InvalidArgumentException;
4+
use PHPUnit\Framework\ExpectationFailedException;
5+
36
/**
7+
* Tests for the sanitize_title() function.
8+
*
49
* @group formatting
510
*
611
* @covers ::sanitize_title
@@ -12,6 +17,11 @@ public function test_strips_html() {
1217
$this->assertSame( $expected, sanitize_title( $input ) );
1318
}
1419

20+
/**
21+
* Tests for the sanitize_title() function leaving Devanagari characters intact.
22+
*
23+
* @ticket 31992
24+
*/
1525
public function test_leaves_devanagari() {
1626
$input = 'राजीव';
1727
$this->assertSame( $input, urldecode( sanitize_title( $input ) ) );

tests/phpunit/tests/formatting/sanitizeUser.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* @group formatting
3+
* Tests for the sanitize_user() function.
54
*
5+
* @group formatting
66
* @covers ::sanitize_user
77
*/
88
class Tests_Formatting_SanitizeUser extends WP_UnitTestCase {
@@ -37,14 +37,13 @@ public function test_strips_encoded_ampersand_when_followed_by_semicolon() {
3737
$this->assertSame( $expected, sanitize_user( 'AT&amp;T Test;' ) );
3838
}
3939

40-
/*
40+
/**
4141
* Some languages use the Latin alphabet with various accents.
4242
* The city Münster is in Germany, Orléans is in France. This
4343
* test checks that an author (a user name) can use an accent.
4444
*
4545
* @ticket 31992
4646
*/
47-
4847
public function test_strips_percent_encoded_octets() {
4948
if ( ! function_exists( 'mb_str_split' ) ) {
5049
$this->markTestSkipped( 'PHP 7.2/3 lacks mb_str_split' );
@@ -57,6 +56,13 @@ public function test_optional_strict_mode_reduces_to_safe_ascii_subset() {
5756
$this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) );
5857
}
5958

59+
/**
60+
* Arabic script is used in various languages, including
61+
* Arabic and Persian. This test checks that an author
62+
* (a user name) can use such letters.
63+
*
64+
* @ticket 31992
65+
*/
6066
public function test_accepts_all_arabic() {
6167
if ( ! function_exists( 'mb_str_split' ) ) {
6268
$this->markTestSkipped( 'PHP 7.2/3 lacks mb_str_split' );
@@ -68,7 +74,7 @@ public function test_accepts_all_arabic() {
6874
$this->assertSame( $expected, sanitize_user( $encoded ) );
6975
}
7076

71-
/*
77+
/**
7278
* Some languages use the Latin alphabet with various
7379
* extra letters. The city Bodø is in Norway, Gießen in
7480
* Germany. This test checks that an author (a user name) can
@@ -78,7 +84,6 @@ public function test_accepts_all_arabic() {
7884
*
7985
* @ticket 31992
8086
*/
81-
8287
public function test_accepts_west_african_latin() {
8388
if ( ! function_exists( 'mb_str_split' ) ) {
8489
$this->markTestSkipped( 'PHP 7.2/3 lacks mb_str_split' );

tests/phpunit/tests/user.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,12 +1120,14 @@ public function test_validate_utf8_usernames() {
11201120
$this->assertTrue( validate_username( 'grå' ) );
11211121
/* Three Cyrillic letters */
11221122
$this->assertTrue( validate_username( 'ІВМ' ) );
1123-
/* A metal umlaut fails because validate_username is
1124-
* strict and n̈ is unfamiliar in every language
1123+
/**
1124+
* A metal umlaut fails because validate_username is
1125+
* strict and n̈ is unfamiliar in every language.
11251126
*/
11261127
$this->assertFalse( validate_username( 'spın̈altap' ) );
1127-
/* Emoji skintones fail because usernames should be
1128-
* easily distinguishable
1128+
/**
1129+
* Emoji skintones fail because usernames should be
1130+
* easily distinguishable.
11291131
*/
11301132
$this->assertFalse( validate_username( '👱🏼' ) );
11311133
$this->assertFalse( validate_username( '👱🏾' ) );

0 commit comments

Comments
 (0)