Skip to content

Commit b95ef97

Browse files
committed
DB/RestrictedFunctions: add tests for namespaced names
1 parent 225676a commit b95ef97

File tree

2 files changed

+51
-41
lines changed

2 files changed

+51
-41
lines changed

WordPress/Tests/DB/RestrictedFunctionsUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,11 @@ WP_Date_Query::build_mysql_datetime(); // Ok.
9494
myFictionFunction(); // Bad.
9595
myFictional(); // OK.
9696
Myfictional(); // OK.
97+
98+
/*
99+
* Safeguard correct handling of all types of namespaced function calls.
100+
*/
101+
\mysql_connect();
102+
MyNamespace\mysql_connect();
103+
\MyNamespace\mysql_connect();
104+
namespace\mysql_connect(); // The sniff should start flagging this once it can resolve relative namespaces.

WordPress/Tests/DB/RestrictedFunctionsUnitTest.php

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -63,54 +63,56 @@ protected function tearDown(): void {
6363
*/
6464
public function getErrorList() {
6565
return array(
66-
25 => 1,
67-
26 => 1,
68-
27 => 1,
69-
28 => 1,
70-
29 => 1,
71-
30 => 1,
72-
31 => 1,
73-
32 => 1,
74-
33 => 1,
66+
25 => 1,
67+
26 => 1,
68+
27 => 1,
69+
28 => 1,
70+
29 => 1,
71+
30 => 1,
72+
31 => 1,
73+
32 => 1,
74+
33 => 1,
7575

76-
36 => 1,
77-
37 => 1,
78-
38 => 1,
79-
39 => 1,
80-
40 => 1,
81-
41 => 1,
82-
42 => 1,
83-
43 => 1,
84-
44 => 1,
76+
36 => 1,
77+
37 => 1,
78+
38 => 1,
79+
39 => 1,
80+
40 => 1,
81+
41 => 1,
82+
42 => 1,
83+
43 => 1,
84+
44 => 1,
8585

86-
47 => 1,
87-
48 => 1,
88-
49 => 1,
89-
50 => 1,
90-
51 => 1,
86+
47 => 1,
87+
48 => 1,
88+
49 => 1,
89+
50 => 1,
90+
51 => 1,
9191

92-
54 => 1,
93-
55 => 1,
94-
56 => 1,
95-
57 => 1,
92+
54 => 1,
93+
55 => 1,
94+
56 => 1,
95+
57 => 1,
9696

97-
60 => 1,
97+
60 => 1,
9898

99-
63 => 1,
99+
63 => 1,
100100

101-
66 => 1,
102-
67 => 1,
103-
68 => 1,
104-
69 => 1,
105-
70 => 1,
106-
71 => 1,
107-
72 => 1,
108-
73 => 1,
109-
74 => 1,
110-
75 => 1,
111-
76 => 1,
101+
66 => 1,
102+
67 => 1,
103+
68 => 1,
104+
69 => 1,
105+
70 => 1,
106+
71 => 1,
107+
72 => 1,
108+
73 => 1,
109+
74 => 1,
110+
75 => 1,
111+
76 => 1,
112112

113-
94 => 1,
113+
94 => 1,
114+
115+
101 => 1,
114116
);
115117
}
116118

0 commit comments

Comments
 (0)