File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Spiral \CodeStyle \Tests \Acceptance ;
6+
7+ use PHPUnit \Framework \Attributes \DoesNotPerformAssertions ;
8+
9+ final class BuilderTest extends TestCase
10+ {
11+ #[DoesNotPerformAssertions]
12+ public function testDisableRisky (): void
13+ {
14+ $ config = \realpath (__DIR__ . '/Stub/config-no-risky.php ' );
15+ $ command = "php vendor/bin/php-cs-fixer fix --dry-run --config= $ config " ;
16+
17+ \exec ($ command , $ output , $ status );
18+
19+ \in_array ($ status , [0 , 8 ]) or $ this ->fail (\sprintf (
20+ "php-cs-fixer failed: %s. \n %s \n\n%s " ,
21+ $ status ,
22+ \implode ('\n ' , $ this ->describeFailCommand ($ status )),
23+ \implode ("\n" , $ output ),
24+ ));
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ require_once './vendor/autoload.php ' ;
6+
7+ return \Spiral \CodeStyle \Builder::create ()
8+ ->include (__FILE__ )
9+ ->allowRisky (false )
10+ ->build ();
Original file line number Diff line number Diff line change 44
55namespace Spiral \CodeStyle \Tests \Acceptance ;
66
7- use PHPUnit \Framework \TestCase ;
8-
97final class StyleTest extends TestCase
108{
11- private const CS_STATUSES = [
12- 1 => 'General error (or PHP minimal requirement not matched). ' ,
13- 4 => 'Some files have invalid syntax (only in dry-run mode). ' ,
14- 8 => 'Some files need fixing (only in dry-run mode). ' ,
15- 16 => 'Configuration error of the application. ' ,
16- 32 => 'Configuration error of a Fixer. ' ,
17- 64 => 'Exception raised within the application. ' ,
18- ];
19-
209 public function testStyled (): void
2110 {
2211 $ dir = \realpath (__DIR__ . '/Stub/Styled ' );
@@ -58,14 +47,4 @@ public function testStyled(): void
5847 )),
5948 ));
6049 }
61-
62- private function describeFailCommand (int $ code ): array
63- {
64- $ result = [];
65- foreach (self ::CS_STATUSES as $ mask => $ description ) {
66- $ code & $ mask and $ result [] = $ description ;
67- }
68-
69- return $ result ;
70- }
7150}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Spiral \CodeStyle \Tests \Acceptance ;
6+
7+ abstract class TestCase extends \PHPUnit \Framework \TestCase
8+ {
9+ private const CS_STATUSES = [
10+ 1 => 'General error (or PHP minimal requirement not matched). ' ,
11+ 4 => 'Some files have invalid syntax (only in dry-run mode). ' ,
12+ 8 => 'Some files need fixing (only in dry-run mode). ' ,
13+ 16 => 'Configuration error of the application. ' ,
14+ 32 => 'Configuration error of a Fixer. ' ,
15+ 64 => 'Exception raised within the application. ' ,
16+ ];
17+
18+ protected function describeFailCommand (int $ code ): array
19+ {
20+ $ result = [];
21+ foreach (self ::CS_STATUSES as $ mask => $ description ) {
22+ $ code & $ mask and $ result [] = $ description ;
23+ }
24+
25+ return $ result ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments