Skip to content

Commit b4d3fb3

Browse files
committed
WP/CapitalPDangit: add tests for namespaced names
1 parent 73265d8 commit b4d3fb3

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

WordPress/Tests/WP/CapitalPDangitUnitTest.1.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,12 @@ class TypeClassConstants {
244244
// Ensures no false positives on incorrect casing in a class constant type name.
245245
public const (\Fully\Qualified\MyClass&wordPRESS)|string ANOTHER_WORDPRESS = 'wordpress';
246246
}
247+
248+
/*
249+
* Safeguard correct handling of all types of namespaced calls to the define() function.
250+
*/
251+
\DEFINE( 'WORDPRESS_SOMETHING', 'wordpress' ); // OK.
252+
MyNamespace\define( 'WORDPRESS_SOMETHING', 'wordpress' ); // Bad.
253+
\MyNamespace\Define( 'WORDPRESS_SOMETHING', 'wordpress' ); // Bad.
254+
namespace\Sub\define( 'WORDPRESS_SOMETHING', 'wordpress' ); // Bad.
255+
namespace\define( 'WORDPRESS_SOMETHING', 'wordpress' ); // The sniff should stop flagging this once it can resolve relative namespaces.

WordPress/Tests/WP/CapitalPDangitUnitTest.1.inc.fixed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,12 @@ class TypeClassConstants {
244244
// Ensures no false positives on incorrect casing in a class constant type name.
245245
public const (\Fully\Qualified\MyClass&wordPRESS)|string ANOTHER_WORDPRESS = 'wordpress';
246246
}
247+
248+
/*
249+
* Safeguard correct handling of all types of namespaced calls to the define() function.
250+
*/
251+
\DEFINE( 'WORDPRESS_SOMETHING', 'wordpress' ); // OK.
252+
MyNamespace\define( 'WORDPRESS_SOMETHING', 'WordPress' ); // Bad.
253+
\MyNamespace\Define( 'WORDPRESS_SOMETHING', 'WordPress' ); // Bad.
254+
namespace\Sub\define( 'WORDPRESS_SOMETHING', 'WordPress' ); // Bad.
255+
namespace\define( 'WORDPRESS_SOMETHING', 'WordPress' ); // The sniff should stop flagging this once it can resolve relative namespaces.

WordPress/Tests/WP/CapitalPDangitUnitTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public function getWarningList( $testFile = '' ) {
6969
204 => 1,
7070
205 => 1,
7171
224 => 1,
72+
252 => 1,
73+
253 => 1,
74+
254 => 1,
75+
255 => 1,
7276
);
7377

7478
case 'CapitalPDangitUnitTest.2.inc':

0 commit comments

Comments
 (0)