Skip to content

Commit 7f684cf

Browse files
run phpcs on tests/ directory too
1 parent a6522c2 commit 7f684cf

21 files changed

+247
-246
lines changed

includes/class-debug-log.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ class MC4WP_Debug_Log
1010
/**
1111
* Detailed debug information
1212
*/
13-
const DEBUG = 100;
13+
public const DEBUG = 100;
1414

1515
/**
1616
* Interesting events
1717
*
1818
* Examples: Visitor subscribed
1919
*/
20-
const INFO = 200;
20+
public const INFO = 200;
2121

2222
/**
2323
* Exceptional occurrences that are not errors
2424
*
2525
* Examples: User already subscribed
2626
*/
27-
const WARNING = 300;
27+
public const WARNING = 300;
2828

2929
/**
3030
* Runtime errors
3131
*/
32-
const ERROR = 400;
32+
public const ERROR = 400;
3333

3434
/**
3535
* Logging levels from syslog protocol defined in RFC 5424

includes/class-queue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MC4WP_Queue
2525
/**
2626
* @var int
2727
*/
28-
const MAX_JOB_COUNT = 1000;
28+
private const MAX_JOB_COUNT = 1000;
2929

3030
/**
3131
* MC4WP_Ecommerce_Queue constructor.

includes/forms/class-output-manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MC4WP_Form_Output_Manager
1616
/**
1717
* @const string
1818
*/
19-
const SHORTCODE = 'mc4wp_form';
19+
private const SHORTCODE = 'mc4wp_form';
2020

2121
/**
2222
* Add hooks

integrations/prosopo-procaptcha/class-procaptcha.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?php
22

3-
defined('ABSPATH') or exit;
4-
53
/**
64
* Class MC4WP_Procaptcha
75
*
86
* @private
97
*/
108
class MC4WP_Procaptcha
119
{
12-
const SCRIPT_URL = 'https://js.prosopo.io/js/procaptcha.bundle.js';
13-
const FORM_FIELD_NAME = 'procaptcha-response';
14-
const API_URL = 'https://api.prosopo.io/siteverify';
10+
private const SCRIPT_URL = 'https://js.prosopo.io/js/procaptcha.bundle.js';
11+
private const FORM_FIELD_NAME = 'procaptcha-response';
12+
private const API_URL = 'https://api.prosopo.io/siteverify';
1513

1614
/**
1715
* @var MC4WP_Procaptcha

phpcs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<file>includes/</file>
88
<file>integrations/</file>
99
<file>config/</file>
10+
<file>tests/</file>
1011
<file>sample-code-snippets/</file>
1112
<exclude-pattern>*\.(html|css|js|md|json|xml|sh)</exclude-pattern>
1213
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>

tests/ContainerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
class ContainerTest extends TestCase
1111
{
12-
1312
/**
1413
* @covers MC4WP_Container::get
1514
*/

tests/DebugLogReaderTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class DebugLogReaderTest extends TestCase
66
{
7-
87
/**
98
* @var string
109
*/
@@ -13,10 +12,10 @@ class DebugLogReaderTest extends TestCase
1312
/**
1413
* @var string
1514
*/
16-
protected array $sample_log_lines = array(
15+
protected array $sample_log_lines = [
1716
'eCommerce360 > Successfully added order 101',
1817
'eCommerce360 > Order 101 deleted',
19-
);
18+
];
2019

2120
/**
2221
* DebugLogReaderTest constructor.

tests/DebugLogTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class DebugLogTest extends TestCase
66
{
7-
87
/**
98
* @var string
109
*/
@@ -121,7 +120,7 @@ public function test_error()
121120
/**
122121
* Remove log files after each test.
123122
*/
124-
public function tearDown() : void
123+
public function tearDown(): void
125124
{
126125
if (file_exists($this->file)) {
127126
unlink($this->file);

tests/FieldFormatterTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use PHPUnit\Framework\TestCase;
34

45
/**
@@ -8,22 +9,21 @@
89
*/
910
class FieldFormatterTest extends TestCase
1011
{
11-
1212
/**
1313
* @covers MC4WP_Field_Formatter::address
1414
*/
1515
public function test_address()
1616
{
1717
$formatter = new MC4WP_Field_Formatter();
1818

19-
$address = array(
19+
$address = [
2020
'addr1' => "795 E DRAGRAM",
2121
'addr2' => '',
2222
'city' => 'TUCSON',
2323
'state' => 'AZ',
2424
'zip' => '85705',
2525
'country' => 'USA'
26-
);
26+
];
2727

2828
// should accept string
2929
$value = $formatter->address(join(',', $address));
@@ -39,7 +39,7 @@ public function test_address()
3939
self::assertArrayHasKey('city', $value);
4040

4141
// partial array value
42-
$value = $formatter->address(array( 'city' => $address['city'] ));
42+
$value = $formatter->address([ 'city' => $address['city'] ]);
4343
self::assertEquals($value['city'], $address['city']);
4444
self::assertArrayHasKey('addr1', $value);
4545
}
@@ -62,11 +62,11 @@ public function test_birthday()
6262
self::assertEquals($birthday, $value);
6363

6464
// array with "day" and "month"
65-
$value = $formatter->birthday(array( 'day' => 29, 'month' => 7 ));
65+
$value = $formatter->birthday([ 'day' => 29, 'month' => 7 ]);
6666
self::assertEquals($birthday, $value);
6767

6868
// simple array
69-
$value = $formatter->birthday(array( 29, 7 ));
69+
$value = $formatter->birthday([ 29, 7 ]);
7070
self::assertEquals($birthday, $value);
7171

7272
// full year
@@ -95,7 +95,7 @@ public function test_date()
9595
self::assertEquals($date, $value);
9696

9797
// array keys
98-
$value = $formatter->date(array( 'day' => 5, 'month' => 5, 'year' => 2016 ));
98+
$value = $formatter->date([ 'day' => 5, 'month' => 5, 'year' => 2016 ]);
9999
self::assertEquals($date, $value);
100100
}
101101

@@ -106,12 +106,12 @@ public function test_boolean()
106106
{
107107
$formatter = new MC4WP_Field_Formatter();
108108

109-
$falsey_tests = array( 'false', '0', 0, false );
109+
$falsey_tests = [ 'false', '0', 0, false ];
110110
foreach ($falsey_tests as $test) {
111111
self::assertEquals(false, $formatter->boolean($test));
112112
}
113113

114-
$truthy_tests = array( 'true', '1', 1, true );
114+
$truthy_tests = [ 'true', '1', 1, true ];
115115
foreach ($truthy_tests as $test) {
116116
self::assertEquals(true, $formatter->boolean($test));
117117
}
@@ -124,15 +124,15 @@ public function test_language()
124124
{
125125
$formatter = new MC4WP_Field_Formatter();
126126

127-
$tests = array(
127+
$tests = [
128128
'pt_PT' => 'pt_PT',
129129
'es_ES' => 'es_ES',
130130
'fr_CA' => 'fr_CA',
131131
'pt_BR' => 'pt',
132132
'fr_FR' => 'fr',
133133
'nl_NL' => 'nl',
134134
'en_US' => 'en',
135-
);
135+
];
136136

137137
foreach ($tests as $input => $output) {
138138
self::assertEquals($formatter->language($input), $output);

tests/FieldGuesserTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use PHPUnit\Framework\TestCase;
34

45
/**
@@ -8,22 +9,21 @@
89
*/
910
class FieldGuesserTest extends TestCase
1011
{
11-
1212
/**
1313
* @covers MC4WP_Field_Guesser::namespaced
1414
*/
1515
public function test_namespaced()
1616
{
17-
$data = array(
17+
$data = [
1818
'prefix-foo' => 'bar',
1919
'foo' => 'barbar'
20-
);
20+
];
2121

2222
$instance = new MC4WP_Field_Guesser($data);
2323
self::assertEquals(
24-
array(
24+
[
2525
'FOO' => 'bar'
26-
),
26+
],
2727
$instance->namespaced('prefix-')
2828
);
2929
}
@@ -33,19 +33,19 @@ public function test_namespaced()
3333
*/
3434
public function test_guessed()
3535
{
36-
$data = array(
36+
$data = [
3737
'name' => 'Danny van Kooten',
3838
'first-name' => 'Danny',
3939
'lname' => 'van Kooten'
40-
);
40+
];
4141

4242
$instance = new MC4WP_Field_Guesser($data);
4343
self::assertEquals(
44-
array(
44+
[
4545
'NAME' => 'Danny van Kooten',
4646
'FNAME' => 'Danny',
4747
'LNAME' => "van Kooten"
48-
),
48+
],
4949
$instance->guessed()
5050
);
5151
}
@@ -55,30 +55,30 @@ public function test_guessed()
5555
*/
5656
public function test_combine()
5757
{
58-
$data = array(
58+
$data = [
5959
'name' => 'Danny van Kooten',
6060
'prefix-email' => 'johndoe@email.com',
6161
'foo' => 'bar'
62-
);
62+
];
6363

6464
$instance = new MC4WP_Field_Guesser($data);
65-
$result = $instance->combine(array( 'namespaced', 'guessed' ));
65+
$result = $instance->combine([ 'namespaced', 'guessed' ]);
6666

6767
self::assertEquals($result['NAME'], $data['name']);
6868
self::assertEquals($result['EMAIL'], $data['prefix-email']);
6969
self::assertArrayNotHasKey('foo', $result);
7070

7171
// test order (latter overwrites former)
72-
$data = array(
72+
$data = [
7373
'name' => 'Danny van Kooten',
7474
'mc4wp-name' => 'Danny Janssen'
75-
);
75+
];
7676

7777
$instance = new MC4WP_Field_Guesser($data);
78-
$result = $instance->combine(array( 'namespaced', 'guessed' ));
78+
$result = $instance->combine([ 'namespaced', 'guessed' ]);
7979
self::assertEquals($result['NAME'], $data['name']);
8080

81-
$result = $instance->combine(array( 'guessed', 'namespaced' ));
81+
$result = $instance->combine([ 'guessed', 'namespaced' ]);
8282
self::assertEquals($result['NAME'], $data['mc4wp-name']);
8383
}
8484
}

0 commit comments

Comments
 (0)