Skip to content

Commit af5f478

Browse files
author
Nikolay Shapovalov
committed
move tests
1 parent 7c7519f commit af5f478

File tree

6 files changed

+90
-18
lines changed

6 files changed

+90
-18
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Contains Test.
6+
*/
7+
8+
/**
9+
* Implements hook_node_view().
10+
*/
11+
#[Hook('hook_node_view')]
12+
function module_node_view() {
13+
14+
}
15+
16+
/**
17+
* Implements hook_piratehook_view().
18+
*/
19+
#[Hook('piratehook_view')]
20+
function module_piratehook_view() {
21+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Contains Test.
6+
*/
7+
8+
/**
9+
* Implements hook_node_view().
10+
*/
11+
#[Hook('node_view')]
12+
function module_node_view() {
13+
14+
}
15+
16+
/**
17+
* Implements hook_piratehook_view().
18+
*/
19+
#[Hook('piratehook_view')]
20+
function module_piratehook_view() {
21+
22+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace Drupal\Test\Attributes;
4+
5+
use Drupal\Test\CoderSniffUnitTest;
6+
7+
class ValidHookNameUnitTest extends CoderSniffUnitTest
8+
{
9+
10+
11+
/**
12+
* Returns the lines where errors should occur.
13+
*
14+
* The key of the array should represent the line number and the value
15+
* should represent the number of errors that should occur on that line.
16+
*
17+
* @param string $testFile The name of the file being tested.
18+
*
19+
* @return array<int, int>
20+
*/
21+
protected function getErrorList(string $testFile): array
22+
{
23+
return [];
24+
25+
}//end getErrorList()
26+
27+
28+
/**
29+
* Returns the lines where warnings should occur.
30+
*
31+
* The key of the array should represent the line number and the value
32+
* should represent the number of warnings that should occur on that line.
33+
*
34+
* @param string $testFile The name of the file being tested.
35+
*
36+
* @return array<int, int>
37+
*/
38+
protected function getWarningList(string $testFile): array
39+
{
40+
return [11 => 1];
41+
42+
}//end getWarningList()
43+
44+
45+
}//end class

tests/Drupal/bad/BadUnitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ protected function getErrorList(string $testFile): array
384384
849 => 2,
385385
860 => 2,
386386
867 => 1,
387-
879 => 2,
387+
871 => 2,
388388
];
389389
}//end switch
390390

@@ -435,7 +435,6 @@ protected function getWarningList(string $testFile): array
435435
823 => 1,
436436
824 => 1,
437437
836 => 1,
438-
874 => 1,
439438
];
440439
}//end switch
441440

tests/Drupal/bad/bad.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,4 @@ function test30(TestType $a = NULL) {
868868
echo "Hello";
869869
}
870870

871-
/**
872-
* Implements hook_node_view().
873-
*/
874-
#[Hook('hook_node_view')]
875-
function bad_node_view() {
876-
877-
}
878-
879871
?>

tests/Drupal/bad/bad.php.fixed

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -921,11 +921,3 @@ function test29(
921921
function test30(?TestType $a = NULL) {
922922
echo "Hello";
923923
}
924-
925-
/**
926-
* Implements hook_node_view().
927-
*/
928-
#[Hook('node_view')]
929-
function bad_node_view() {
930-
931-
}

0 commit comments

Comments
 (0)