From 85f30163edeb4d0d03895af5bcbac537ebc28135 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 3 Oct 2019 09:43:14 +0200 Subject: [PATCH] CapitalPDangit: minor tweak Allow for the `test` TLD. Includes unit test. --- WordPress/Sniffs/WP/CapitalPDangitSniff.php | 4 ++-- WordPress/Tests/WP/CapitalPDangitUnitTest.inc | 3 +++ WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/WP/CapitalPDangitSniff.php b/WordPress/Sniffs/WP/CapitalPDangitSniff.php index edbd3ebe97..bf98233fb9 100644 --- a/WordPress/Sniffs/WP/CapitalPDangitSniff.php +++ b/WordPress/Sniffs/WP/CapitalPDangitSniff.php @@ -28,7 +28,7 @@ class CapitalPDangitSniff extends Sniff { * Regex to match a large number or spelling variations of WordPress in text strings. * * Prevents matches on: - * - URLs for wordpress.org/com/net/tv. + * - URLs for wordpress.org/com/net/test/tv. * - `@...` usernames starting with `wordpress` * - email addresses with a domain starting with `wordpress` * - email addresses with a user name ending with `wordpress` @@ -42,7 +42,7 @@ class CapitalPDangitSniff extends Sniff { * * @var string */ - const WP_REGEX = '#(?\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i'; + const WP_REGEX = '#(?\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i'; /** * Regex to match a large number or spelling variations of WordPress in class names. diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc index 33622aa88c..e29ee8942f 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc @@ -188,3 +188,6 @@ class TestMe { ANOTHER => array( 'a' => 'b' ), WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly). } + +// Allow "test" domain. +$value = function_call( 'git.wordpress.test' ); diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed index 7dc636aa88..0a00f5ec0d 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed @@ -188,3 +188,6 @@ class TestMe { ANOTHER => array( 'a' => 'b' ), WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly). } + +// Allow "test" domain. +$value = function_call( 'git.wordpress.test' );