Skip to content

Commit 0f46b15

Browse files
author
Nikolay Shapovalov
committed
update tests
1 parent 9c6f937 commit 0f46b15

File tree

3 files changed

+173
-1
lines changed

3 files changed

+173
-1
lines changed

tests/Drupal/Attributes/ValidHookNameUnitTest.inc

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,107 @@
77

88
/**
99
* Implements hook_node_view().
10+
*
11+
* Single quotes.
1012
*/
1113
#[Hook('hook_node_view')]
1214
function module_node_view() {
1315

1416
}
1517

18+
/**
19+
* Implements hook_node_load().
20+
*
21+
* Double quotes.
22+
*/
23+
#[Hook("hook_node_load")]
24+
function module_node_load() {
25+
26+
}
27+
28+
29+
/**
30+
* Implements hook_node_delete().
31+
*/
32+
#[Hook(hook: 'hook_node_delete')]
33+
function module_node_delete() {
34+
35+
}
36+
37+
/**
38+
* Implements hook_node_alter().
39+
*/
40+
#[Hook(hook: 'hook_node_alter', module: 'custom_module')]
41+
function module_node_alter() {
42+
43+
}
44+
1645
/**
1746
* Implements hook_piratehook_view().
47+
*
48+
* "hook" is a part of hook name. No warning.
1849
*/
1950
#[Hook('piratehook_view')]
2051
function module_piratehook_view() {
2152

2253
}
2354

55+
/**
56+
* Implements hook_hookpirate_view().
57+
*
58+
* "hook" is a part of hook name. No warning.
59+
*/
60+
#[Hook('hookpirate_view')]
61+
function module_hookpirate_view() {
62+
63+
}
64+
2465
/**
2566
* Implements hook_hook_info().
67+
*
68+
* "hook_info" is exception. No warning.
2669
*/
2770
#[Hook('hook_info')]
2871
function module_hook_info() {
2972

3073
}
74+
75+
/**
76+
* Implements hook_hook_info().
77+
*
78+
* "hook_info" is exception. No warning.
79+
*/
80+
#[Hook(hook: 'hook_info')]
81+
function module_custom_hook_info() {
82+
83+
}
84+
85+
/**
86+
*
87+
*/
88+
#[Hook('hook_user_cancel', 'userCancel', 'custom')]
89+
class Hooks {
90+
91+
/**
92+
*
93+
*/
94+
public function userCancel() {
95+
96+
}
97+
98+
}
99+
100+
/**
101+
*
102+
*/
103+
#[Hook(hook: "hook_user_login", method: "userLogin", module: "views")]
104+
class MyHooks {
105+
106+
/**
107+
*
108+
*/
109+
public function userLogin() {
110+
111+
}
112+
113+
}

tests/Drupal/Attributes/ValidHookNameUnitTest.inc.fixed

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,106 @@
77

88
/**
99
* Implements hook_node_view().
10+
*
11+
* Single quotes.
1012
*/
1113
#[Hook('node_view')]
1214
function module_node_view() {
1315

1416
}
1517

18+
/**
19+
* Implements hook_node_load().
20+
*
21+
* Double quotes.
22+
*/
23+
#[Hook("node_load")]
24+
function module_node_load() {
25+
26+
}
27+
28+
/**
29+
* Implements hook_node_delete().
30+
*/
31+
#[Hook(hook: 'node_delete')]
32+
function module_node_delete() {
33+
34+
}
35+
36+
/**
37+
* Implements hook_node_alter().
38+
*/
39+
#[Hook(hook: 'node_alter', module: 'custom_module')]
40+
function module_node_alter() {
41+
42+
}
43+
1644
/**
1745
* Implements hook_piratehook_view().
46+
*
47+
* "hook" is a part of hook name. No warning.
1848
*/
1949
#[Hook('piratehook_view')]
2050
function module_piratehook_view() {
2151

2252
}
2353

54+
/**
55+
* Implements hook_hookpirate_view().
56+
*
57+
* "hook" is a part of hook name. No warning.
58+
*/
59+
#[Hook('hookpirate_view')]
60+
function module_hookpirate_view() {
61+
62+
}
63+
2464
/**
2565
* Implements hook_hook_info().
66+
*
67+
* "hook_info" is exception. No warning.
2668
*/
2769
#[Hook('hook_info')]
2870
function module_hook_info() {
2971

3072
}
73+
74+
/**
75+
* Implements hook_hook_info().
76+
*
77+
* "hook_info" is exception. No warning.
78+
*/
79+
#[Hook(hook: 'hook_info')]
80+
function module_custom_hook_info() {
81+
82+
}
83+
84+
/**
85+
*
86+
*/
87+
#[Hook('user_cancel', 'userCancel', 'custom')]
88+
class Hooks {
89+
90+
/**
91+
*
92+
*/
93+
public function userCancel() {
94+
95+
}
96+
97+
}
98+
99+
/**
100+
*
101+
*/
102+
#[Hook(hook: "user_login", method: "userLogin", module: "views")]
103+
class MyHooks {
104+
105+
/**
106+
*
107+
*/
108+
public function userLogin() {
109+
110+
}
111+
112+
}

tests/Drupal/Attributes/ValidHookNameUnitTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ protected function getErrorList(string $testFile): array
3737
*/
3838
protected function getWarningList(string $testFile): array
3939
{
40-
return [11 => 1];
40+
return [
41+
13 => 1,
42+
23 => 1,
43+
32 => 1,
44+
40 => 1,
45+
88 => 1,
46+
103 => 1,
47+
];
4148

4249
}//end getWarningList()
4350

0 commit comments

Comments
 (0)