Skip to content

Commit ce615fa

Browse files
committed
WP/CapitalPDangit: add tests for namespaced names
1 parent b2e3d0f commit ce615fa

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

WordPress/Tests/WP/CapitalPDangitUnitTest.1.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,11 @@ 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\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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,11 @@ 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\define( 'WORDPRESS_SOMETHING', 'WordPress' ); // The sniff should stop flagging this once it can resolve relative namespaces.

WordPress/Tests/WP/CapitalPDangitUnitTest.php

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

7477
case 'CapitalPDangitUnitTest.2.inc':

0 commit comments

Comments
 (0)