File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
tests/VerbalExpressions/PHPVerbalExpressions Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 8
8
"require-dev" : {
9
9
"phpunit/phpunit" : " ^5.1"
10
10
},
11
+ "suggest" : {
12
+ "fabpot/php-cs-fixer" : " PHP CS Fixer (testing for PSR-2 compliance)"
13
+ },
11
14
"minimum-stability" : " stable" ,
12
15
"autoload" : {
13
16
"psr-0" : {
Original file line number Diff line number Diff line change @@ -561,4 +561,54 @@ public function testReplace(){
561
561
$ this ->assertEquals ('/foo/mg ' , $ regex ->getRegex ());
562
562
$ this ->assertEquals ('bazbarbaz ' , $ regex ->replace ('foobarfoo ' , 'baz ' ));
563
563
}
564
+
565
+
566
+ public function testPsr2 (){
567
+ $ pathToRoot = dirname (dirname (dirname (__DIR__ )));
568
+ $ pathToVendor = $ pathToRoot . '/vendor ' ;
569
+ $ pathToSrc = $ pathToRoot . '/src ' ;
570
+ $ pathToTests = $ pathToRoot . '/tests ' ;
571
+
572
+ if (
573
+ !is_dir ($ pathToVendor )
574
+ ){
575
+ $ this ->markTestSkipped ('Vendor directory not found. ' );
576
+ return ;
577
+ }else if (
578
+ !is_dir ($ pathToSrc )
579
+ ){
580
+ $ this ->markTestSkipped ('Source directory not found. ' );
581
+ return ;
582
+ }else if (
583
+ !is_dir ($ pathToTests )
584
+ ){
585
+ $ this ->markTestSkipped ('Tests directory not found. ' );
586
+ return ;
587
+ }
588
+
589
+ foreach (array (
590
+ $ pathToTests ,
591
+ $ pathToSrc ,
592
+ ) as $ dirToCheck ){
593
+ $ cmd = escapeshellcmd (
594
+ 'php-cs-fixer fix --level=psr2 --dry-run ' . $ dirToCheck
595
+ );
596
+ exec ($ cmd , $ output , $ return_var );
597
+ if ($ output ){
598
+ array_pop ($ output );
599
+ $ output = array_map ('trim ' , $ output );
600
+ }
601
+
602
+ $ this ->assertEquals (
603
+ 0 ,
604
+ $ return_var ,
605
+ (
606
+ 'PSR-2 linter reported errors in ' .
607
+ $ dirToCheck .
608
+ '/: ' .
609
+ implode ('; ' , $ output )
610
+ )
611
+ );
612
+ }
613
+ }
564
614
}
You can’t perform that action at this time.
0 commit comments