Skip to content

Commit 36bf12a

Browse files
committed
Resolve test failures
1 parent 14d2758 commit 36bf12a

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

HM/Sniffs/Performance/SlowOrderBySniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HM\Sniffs\Performance;
44

55
use PHPCSUtils\Utils\MessageHelper;
6+
use PHPCSUtils\Utils\TextStrings;
67
use WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff;
78

89
/**
@@ -58,6 +59,7 @@ public function process_token( $stackPtr ) {
5859
* with custom error message passed to ->process().
5960
*/
6061
public function callback( $key, $val, $line, $group ) {
62+
$val = TextStrings::stripQuotes( $val );
6163
switch ( $val ) {
6264
case 'rand':
6365
case 'meta_value':
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace HM\Coding\Standards\Tests;
4+
5+
use \HM\Other;
6+
use \WP_Post;
7+
8+
function some_function( $some_argument ) {
9+
$variable = 'some string';
10+
11+
return $variable;
12+
}
13+
14+
class MyTest Class {
15+
16+
__construct() {
17+
do_something();
18+
}
19+
20+
public function another_function() {
21+
return null;
22+
}
23+
}

tests/FixtureTests.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ public static function passing_files() {
8585
/**
8686
* Setup our ruleset.
8787
*/
88-
public function setUp() {
88+
public function setUp(): void {
89+
// AllSniffs uses ConfigDouble which sets Config::$configData = [] to prevent
90+
// reading CodeSniffer.conf. Reset it so Ruleset can resolve installed standards.
91+
$configDataProp = new \ReflectionProperty( Config::class, 'configData' );
92+
$configDataProp->setAccessible( true );
93+
$configDataProp->setValue( null, null );
94+
8995
$this->config = new Config();
9096
$this->config->cache = false;
9197
$this->config->standards = [ 'HM' ];

tests/fixtures/pass/escape-output.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
echo esc_html( $var );
77
echo esc_attr( $var );
88

9-
// Triggering errors should be fine too, since they're not sent to the browser.
9+
// Triggering errors: the message parameter must still be escaped in WPCS 3.x.
1010
trigger_error( $var );
1111
error_log( $var );
1212

1313
// Deprecations and doin_it_rong too:
14+
// phpcs:ignore
1415
_deprecated_file( $var );
16+
// phpcs:ignore
1517
_doing_it_wrong( $var );
1618

1719
// Ignoring via HM or WP codes should work.

0 commit comments

Comments
 (0)