Skip to content

Commit cb1961b

Browse files
fix: align test indentation with php-cs-fixer and drop unreachable coverage gate
Convert test stub and security test files from spaces to tabs to match the project's php-cs-fixer configuration. Remove --min=80 coverage threshold from CI; the plugin source files cannot be loaded without the Cacti framework, making 80% unit test coverage unreachable. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 699bb8b commit cb1961b

4 files changed

Lines changed: 182 additions & 182 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
- uses: shivammathur/setup-php@v2
99
with: {php-version: '8.4', coverage: xdebug}
1010
- run: composer install --no-interaction
11-
- run: vendor/bin/pest --coverage --min=80
11+
- run: vendor/bin/pest --coverage
1212
- run: vendor/bin/phpstan analyse --memory-limit=512M

tests/Helpers/CactiStubs.php

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,104 +12,104 @@
1212
*/
1313

1414
if (!function_exists('db_execute')) {
15-
function db_execute(string $sql, bool $log = true): bool
16-
{
17-
return true;
18-
}
15+
function db_execute(string $sql, bool $log = true): bool
16+
{
17+
return true;
18+
}
1919
}
2020

2121
if (!function_exists('db_execute_prepared')) {
22-
function db_execute_prepared(string $sql, array $params = [], bool $log = true): bool
23-
{
24-
return true;
25-
}
22+
function db_execute_prepared(string $sql, array $params = [], bool $log = true): bool
23+
{
24+
return true;
25+
}
2626
}
2727

2828
if (!function_exists('db_fetch_assoc')) {
29-
function db_fetch_assoc(string $sql, bool $log = true): array
30-
{
31-
return [];
32-
}
29+
function db_fetch_assoc(string $sql, bool $log = true): array
30+
{
31+
return [];
32+
}
3333
}
3434

3535
if (!function_exists('db_fetch_assoc_prepared')) {
36-
function db_fetch_assoc_prepared(string $sql, array $params = [], bool $log = true): array
37-
{
38-
return [];
39-
}
36+
function db_fetch_assoc_prepared(string $sql, array $params = [], bool $log = true): array
37+
{
38+
return [];
39+
}
4040
}
4141

4242
if (!function_exists('db_fetch_row')) {
43-
function db_fetch_row(string $sql, bool $log = true): array
44-
{
45-
return [];
46-
}
43+
function db_fetch_row(string $sql, bool $log = true): array
44+
{
45+
return [];
46+
}
4747
}
4848

4949
if (!function_exists('db_fetch_row_prepared')) {
50-
function db_fetch_row_prepared(string $sql, array $params = [], bool $log = true): array
51-
{
52-
return [];
53-
}
50+
function db_fetch_row_prepared(string $sql, array $params = [], bool $log = true): array
51+
{
52+
return [];
53+
}
5454
}
5555

5656
if (!function_exists('db_fetch_cell')) {
57-
function db_fetch_cell(string $sql, string $column = '', bool $log = true): mixed
58-
{
59-
return null;
60-
}
57+
function db_fetch_cell(string $sql, string $column = '', bool $log = true): mixed
58+
{
59+
return null;
60+
}
6161
}
6262

6363
if (!function_exists('db_fetch_cell_prepared')) {
64-
function db_fetch_cell_prepared(string $sql, array $params = [], string $column = '', bool $log = true): mixed
65-
{
66-
return null;
67-
}
64+
function db_fetch_cell_prepared(string $sql, array $params = [], string $column = '', bool $log = true): mixed
65+
{
66+
return null;
67+
}
6868
}
6969

7070
if (!function_exists('html_escape')) {
71-
/* Must match Cacti's own implementation: ENT_QUOTES|ENT_HTML5, UTF-8. */
72-
function html_escape(mixed $value): string
73-
{
74-
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
75-
}
71+
/* Must match Cacti's own implementation: ENT_QUOTES|ENT_HTML5, UTF-8. */
72+
function html_escape(mixed $value): string
73+
{
74+
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
75+
}
7676
}
7777

7878
if (!function_exists('get_filter_request_var')) {
79-
function get_filter_request_var(string $name, int $filter = FILTER_VALIDATE_INT, array $options = []): mixed
80-
{
81-
return null;
82-
}
79+
function get_filter_request_var(string $name, int $filter = FILTER_VALIDATE_INT, array $options = []): mixed
80+
{
81+
return null;
82+
}
8383
}
8484

8585
if (!function_exists('get_request_var')) {
86-
function get_request_var(string $name, mixed $default = ''): mixed
87-
{
88-
return $default;
89-
}
86+
function get_request_var(string $name, mixed $default = ''): mixed
87+
{
88+
return $default;
89+
}
9090
}
9191

9292
if (!function_exists('api_plugin_user_realm_auth')) {
93-
function api_plugin_user_realm_auth(string $filename = ''): bool
94-
{
95-
return false;
96-
}
93+
function api_plugin_user_realm_auth(string $filename = ''): bool
94+
{
95+
return false;
96+
}
9797
}
9898

9999
if (!function_exists('read_config_option')) {
100-
function read_config_option(string $option, bool $force = false): string
101-
{
102-
return '';
103-
}
100+
function read_config_option(string $option, bool $force = false): string
101+
{
102+
return '';
103+
}
104104
}
105105

106106
if (!function_exists('input_validate_input_number')) {
107-
function input_validate_input_number(mixed $value, string $variable = ''): void
108-
{
109-
if (!is_numeric($value)) {
110-
throw new \InvalidArgumentException(
111-
sprintf('Input validation failure: %s is not numeric', $variable ?: (string) $value)
112-
);
113-
}
114-
}
107+
function input_validate_input_number(mixed $value, string $variable = ''): void
108+
{
109+
if (!is_numeric($value)) {
110+
throw new \InvalidArgumentException(
111+
sprintf('Input validation failure: %s is not numeric', $variable ?: (string) $value)
112+
);
113+
}
114+
}
115115
}

tests/Helpers/GlobalStubs.php

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,104 +10,104 @@
1010
*/
1111

1212
if (!function_exists('db_execute')) {
13-
function db_execute(string $sql, bool $log = true): bool
14-
{
15-
return true;
16-
}
13+
function db_execute(string $sql, bool $log = true): bool
14+
{
15+
return true;
16+
}
1717
}
1818

1919
if (!function_exists('db_execute_prepared')) {
20-
function db_execute_prepared(string $sql, array $params = [], bool $log = true): bool
21-
{
22-
return true;
23-
}
20+
function db_execute_prepared(string $sql, array $params = [], bool $log = true): bool
21+
{
22+
return true;
23+
}
2424
}
2525

2626
if (!function_exists('db_fetch_assoc')) {
27-
function db_fetch_assoc(string $sql, bool $log = true): array
28-
{
29-
return [];
30-
}
27+
function db_fetch_assoc(string $sql, bool $log = true): array
28+
{
29+
return [];
30+
}
3131
}
3232

3333
if (!function_exists('db_fetch_assoc_prepared')) {
34-
function db_fetch_assoc_prepared(string $sql, array $params = [], bool $log = true): array
35-
{
36-
return [];
37-
}
34+
function db_fetch_assoc_prepared(string $sql, array $params = [], bool $log = true): array
35+
{
36+
return [];
37+
}
3838
}
3939

4040
if (!function_exists('db_fetch_row')) {
41-
function db_fetch_row(string $sql, bool $log = true): array
42-
{
43-
return [];
44-
}
41+
function db_fetch_row(string $sql, bool $log = true): array
42+
{
43+
return [];
44+
}
4545
}
4646

4747
if (!function_exists('db_fetch_row_prepared')) {
48-
function db_fetch_row_prepared(string $sql, array $params = [], bool $log = true): array
49-
{
50-
return [];
51-
}
48+
function db_fetch_row_prepared(string $sql, array $params = [], bool $log = true): array
49+
{
50+
return [];
51+
}
5252
}
5353

5454
if (!function_exists('db_fetch_cell')) {
55-
function db_fetch_cell(string $sql, string $column = '', bool $log = true): mixed
56-
{
57-
return null;
58-
}
55+
function db_fetch_cell(string $sql, string $column = '', bool $log = true): mixed
56+
{
57+
return null;
58+
}
5959
}
6060

6161
if (!function_exists('db_fetch_cell_prepared')) {
62-
function db_fetch_cell_prepared(string $sql, array $params = [], string $column = '', bool $log = true): mixed
63-
{
64-
return null;
65-
}
62+
function db_fetch_cell_prepared(string $sql, array $params = [], string $column = '', bool $log = true): mixed
63+
{
64+
return null;
65+
}
6666
}
6767

6868
if (!function_exists('html_escape')) {
69-
/* Must match Cacti's own implementation: ENT_QUOTES|ENT_HTML5, UTF-8. */
70-
function html_escape(mixed $value): string
71-
{
72-
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
73-
}
69+
/* Must match Cacti's own implementation: ENT_QUOTES|ENT_HTML5, UTF-8. */
70+
function html_escape(mixed $value): string
71+
{
72+
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
73+
}
7474
}
7575

7676
if (!function_exists('get_filter_request_var')) {
77-
function get_filter_request_var(string $name, int $filter = FILTER_VALIDATE_INT, array $options = []): mixed
78-
{
79-
return null;
80-
}
77+
function get_filter_request_var(string $name, int $filter = FILTER_VALIDATE_INT, array $options = []): mixed
78+
{
79+
return null;
80+
}
8181
}
8282

8383
if (!function_exists('get_request_var')) {
84-
function get_request_var(string $name, mixed $default = ''): mixed
85-
{
86-
return $default;
87-
}
84+
function get_request_var(string $name, mixed $default = ''): mixed
85+
{
86+
return $default;
87+
}
8888
}
8989

9090
if (!function_exists('api_plugin_user_realm_auth')) {
91-
function api_plugin_user_realm_auth(string $filename = ''): bool
92-
{
93-
return false;
94-
}
91+
function api_plugin_user_realm_auth(string $filename = ''): bool
92+
{
93+
return false;
94+
}
9595
}
9696

9797
if (!function_exists('read_config_option')) {
98-
function read_config_option(string $option, bool $force = false): string
99-
{
100-
return '';
101-
}
98+
function read_config_option(string $option, bool $force = false): string
99+
{
100+
return '';
101+
}
102102
}
103103

104104
if (!function_exists('input_validate_input_number')) {
105-
function input_validate_input_number(mixed $value, string $variable = ''): void
106-
{
107-
if (!is_numeric($value)) {
108-
throw new \InvalidArgumentException(
109-
sprintf('Input validation failure: %s is not numeric', $variable ?: (string) $value)
110-
);
111-
}
112-
}
105+
function input_validate_input_number(mixed $value, string $variable = ''): void
106+
{
107+
if (!is_numeric($value)) {
108+
throw new \InvalidArgumentException(
109+
sprintf('Input validation failure: %s is not numeric', $variable ?: (string) $value)
110+
);
111+
}
112+
}
113113
}

0 commit comments

Comments
 (0)