Skip to content

Commit db3d415

Browse files
BackEndTeakeradus
authored andcommitted
Add test cases for header comment and declare strict
The priority test is to make sure no old behaviour gets broken the misc one is to make sure we fix the bug. Plus tests for the header coment fixer itself if chosen to go that way
1 parent 2a2c9db commit db3d415

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

tests/AutoReview/FixerFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function provideFixersPriorityCases()
8787
[$fixers['combine_nested_dirname'], $fixers['no_spaces_inside_parenthesis']],
8888
[$fixers['declare_strict_types'], $fixers['blank_line_after_opening_tag']],
8989
[$fixers['declare_strict_types'], $fixers['declare_equal_normalize']],
90+
[$fixers['declare_strict_types'], $fixers['header_comment']],
9091
[$fixers['dir_constant'], $fixers['combine_nested_dirname']],
9192
[$fixers['doctrine_annotation_array_assignment'], $fixers['doctrine_annotation_spaces']],
9293
[$fixers['elseif'], $fixers['braces']],

tests/Fixer/Comment/HeaderCommentFixerTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,65 @@ public function provideFixCases()
304304
305305
echo \'x\';',
306306
],
307+
[
308+
[
309+
'header' => 'foo',
310+
'location' => 'after_open',
311+
'separate' => 'bottom',
312+
'commentType' => 'PHPDoc',
313+
],
314+
'<?php
315+
/**
316+
* foo
317+
*/
318+
319+
declare(strict_types=1);
320+
321+
namespace A;
322+
323+
echo 1;',
324+
'<?php
325+
326+
declare(strict_types=1);
327+
/**
328+
* foo
329+
*/
330+
331+
namespace A;
332+
333+
echo 1;'
334+
],
335+
[
336+
[
337+
'header' => 'foo',
338+
'location' => 'after_open',
339+
'separate' => 'bottom',
340+
'commentType' => 'PHPDoc',
341+
],
342+
'<?php
343+
/**
344+
* foo
345+
*/
346+
347+
declare(strict_types=1);
348+
/**
349+
* bar
350+
*/
351+
352+
namespace A;
353+
354+
echo 1;',
355+
'<?php
356+
357+
declare(strict_types=1);
358+
/**
359+
* bar
360+
*/
361+
362+
namespace A;
363+
364+
echo 1;'
365+
],
307366
];
308367
}
309368

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Integration of fixers: header_comment, declare_strict_types
3+
--RULESET--
4+
{
5+
"header_comment" :
6+
{
7+
"commentType": "PHPDoc", "header": "Header Comment", "location": "after_open", "separate": "bottom"
8+
},
9+
"declare_strict_types": true
10+
}
11+
--REQUIREMENTS--
12+
{"php": 70000}
13+
--EXPECT--
14+
<?php
15+
/**
16+
* Header Comment
17+
*/
18+
19+
declare(strict_types=1);
20+
/**
21+
* Header Comment
22+
*/
23+
24+
namespace A\B\C;
25+
26+
class A {
27+
}
28+
29+
--INPUT--
30+
<?php
31+
/**
32+
* Header Comment
33+
*/
34+
35+
namespace A\B\C;
36+
37+
class A {
38+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Integration of fixers: header_comment, declare_strict_types
3+
--RULESET--
4+
{
5+
"header_comment" :
6+
{
7+
"commentType": "PHPDoc", "header": "Header Comment", "location": "after_open", "separate": "bottom"
8+
},
9+
"declare_strict_types": true
10+
}
11+
--REQUIREMENTS--
12+
{"php": 70000}
13+
--EXPECT--
14+
<?php
15+
/**
16+
* Header Comment
17+
*/
18+
19+
declare(strict_types=1);
20+
namespace A\B\C;
21+
22+
class A {
23+
}
24+
25+
--INPUT--
26+
<?php
27+
28+
namespace A\B\C;
29+
30+
class A {
31+
}

0 commit comments

Comments
 (0)