1; Class that follow the naming convention of PHPUnit test classes
2; and that doesn't have the abstract modifier
3; and have a method that follow the naming convention of PHPUnit test methods
4; and the method is public
5(
6 (class_declaration
7 modifier: (_)? @_modifier
8 (#not-eq? @_modifier "abstract")
9 name: (_) @_name
10 (#match? @_name ".*Test$")
11 body: (declaration_list
12 (method_declaration
13 (visibility_modifier)? @_visibility
14 (#eq? @_visibility "public")
15 name: (_) @run
16 (#match? @run "^test.*")
17 )
18 )
19 ) @phpunit-test
20 (#set! tag phpunit-test)
21)
22
23; Class that follow the naming convention of PHPUnit test classes
24; and that doesn't have the abstract modifier
25; and have a method that has the @test annotation
26; and the method is public
27(
28 (class_declaration
29 modifier: (_)? @_modifier
30 (#not-eq? @_modifier "abstract")
31 name: (_) @_name
32 (#match? @_name ".*Test$")
33 body: (declaration_list
34 ((comment) @_comment
35 (#match? @_comment ".*@test\\b.*")
36 .
37 (method_declaration
38 (visibility_modifier)? @_visibility
39 (#eq? @_visibility "public")
40 name: (_) @run
41 (#not-match? @run "^test.*")
42 ))
43 )
44 ) @phpunit-test
45 (#set! tag phpunit-test)
46)
47
48; Class that follow the naming convention of PHPUnit test classes
49; and that doesn't have the abstract modifier
50; and have a method that has the #[Test] attribute
51; and the method is public
52(
53 (class_declaration
54 modifier: (_)? @_modifier
55 (#not-eq? @_modifier "abstract")
56 name: (_) @_name
57 (#match? @_name ".*Test$")
58 body: (declaration_list
59 (method_declaration
60 (attribute_list
61 (attribute_group
62 (attribute (name) @_attribute)
63 )
64 )
65 (#eq? @_attribute "Test")
66 (visibility_modifier)? @_visibility
67 (#eq? @_visibility "public")
68 name: (_) @run
69 (#not-match? @run "^test.*")
70 )
71 )
72 ) @phpunit-test
73 (#set! tag phpunit-test)
74)
75
76; Class that follow the naming convention of PHPUnit test classes
77; and that doesn't have the abstract modifier
78(
79 (class_declaration
80 modifier: (_)? @_modifier
81 (#not-eq? @_modifier "abstract")
82 name: (_) @run
83 (#match? @run ".*Test$")
84 ) @phpunit-test
85 (#set! tag phpunit-test)
86)
87
88; Add support for Pest runnable
89; Function expression that has `it`, `test` or `describe` as the function name
90(
91 (function_call_expression
92 function: (_) @_name
93 (#any-of? @_name "it" "test" "describe")
94 arguments: (arguments
95 .
96 (argument
97 [
98 (encapsed_string (string_value) @run)
99 (string (string_value) @run)
100 ]
101 )
102 )
103 ) @pest-test
104 (#set! tag pest-test)
105)