Browse Source

PhpUnitNoExpectationAnnotationFixer - expectation extracted from annotation shall be separated from rest of code with one blank line

Dariusz Ruminski 7 years ago
parent
commit
878453b664

+ 5 - 0
src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php

@@ -265,6 +265,11 @@ final class MyTest extends \PHPUnit_Framework_TestCase
             $tokens[$docBlockIndex] = new Token([T_DOC_COMMENT, $doc->getContent()]);
             $tokens->insertAt($braceIndex + 1, $newMethods);
 
+            $tokens[$braceIndex + $newMethods->getSize() + 1] = new Token([
+                T_WHITESPACE,
+                $this->whitespacesConfig->getLineEnding().$tokens[$braceIndex + $newMethods->getSize() + 1]->getContent(),
+            ]);
+
             $i = $docBlockIndex;
         }
     }

+ 12 - 0
tests/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixerTest.php

@@ -50,6 +50,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -74,6 +75,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -98,6 +100,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class, \'foo@bar\');
+
             aaa();
         }
     }',
@@ -123,6 +126,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class, null, 123);
+
             aaa();
         }
     }',
@@ -148,6 +152,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class, \'foo\', 123);
+
             aaa();
         }
     }',
@@ -190,6 +195,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedExceptionRegExp(\FooException::class, \'/foo.*$/\');
+
             aaa();
         }
     }',
@@ -216,6 +222,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\'\FooException\');
+
             aaa();
         }
     }',
@@ -245,6 +252,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc($param)
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -273,6 +281,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         function testFnc($param)
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -297,6 +306,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         final function testFnc($param)
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -326,6 +336,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         final function testFnc($param)
         {
             $this->setExpectedException(\FooException::class);
+
             aaa();
         }
     }',
@@ -405,6 +416,7 @@ final class PhpUnitNoExpectationAnnotationFixerTest extends AbstractFixerTestCas
         public function testFnc()
         {
             $this->setExpectedException(\FooException::class, \'foo\', 123);
+
             aaa();
         }
     }',

+ 1 - 0
tests/Fixtures/Integration/priority/php_unit_no_expectation_annotation,no_empty_phpdoc.test

@@ -10,6 +10,7 @@ class FooTest extends \PHPUnit_Framework_TestCase
     public function testFoo()
     {
         $this->setExpectedException(\FooException::class, 'foo', 123);
+
         foo();
     }
 }

+ 1 - 0
tests/Fixtures/Integration/priority/php_unit_no_expectation_annotation,php_unit_expectation.test

@@ -13,6 +13,7 @@ class FooTest extends \PHPUnit_Framework_TestCase
         $this->expectException(\FooException::class);
         $this->expectExceptionMessage(null);
         $this->expectExceptionCode(123);
+
         foo();
     }
 }

+ 1 - 0
tests/Fixtures/Integration/set/@PHPUnit32Migration-risky.test-out.php

@@ -14,6 +14,7 @@ class FooTest extends \PHPUnit_Framework_TestCase {
     function test_php_unit_no_expectation_annotation_32()
     {
         $this->setExpectedException(\FooException::class, null, 123);
+
         bbb();
     }
 }

+ 1 - 0
tests/Fixtures/Integration/set/@PHPUnit35Migration-risky.test-out.php

@@ -14,6 +14,7 @@ class FooTest extends \PHPUnit_Framework_TestCase {
     function test_php_unit_no_expectation_annotation_32()
     {
         $this->setExpectedException(\FooException::class, null, 123);
+
         bbb();
     }
 }

+ 2 - 0
tests/Fixtures/Integration/set/@PHPUnit43Migration-risky.test-out.php

@@ -14,6 +14,7 @@ class FooTest extends \PHPUnit_Framework_TestCase {
     function test_php_unit_no_expectation_annotation_32()
     {
         $this->setExpectedException(\FooException::class, null, 123);
+
         bbb();
     }
 
@@ -23,6 +24,7 @@ class FooTest extends \PHPUnit_Framework_TestCase {
     function test_php_unit_no_expectation_annotation_43()
     {
         $this->setExpectedExceptionRegExp(\FooException::class, '/foo.*$/', 123);
+
         ccc();
     }
 }

+ 2 - 0
tests/Fixtures/Integration/set/@PHPUnit48Migration-risky.test-out.php

@@ -23,6 +23,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
     function test_php_unit_no_expectation_annotation_32()
     {
         $this->setExpectedException(\FooException::class, null, 123);
+
         bbb();
     }
 
@@ -32,6 +33,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
     function test_php_unit_no_expectation_annotation_43()
     {
         $this->setExpectedExceptionRegExp(\FooException::class, '/foo.*$/', 123);
+
         ccc();
     }
 }

+ 2 - 0
tests/Fixtures/Integration/set/@PHPUnit50Migration-risky.test-out.php

@@ -23,6 +23,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
     function test_php_unit_no_expectation_annotation_32()
     {
         $this->setExpectedException(\FooException::class, null, 123);
+
         bbb();
     }
 
@@ -32,6 +33,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
     function test_php_unit_no_expectation_annotation_43()
     {
         $this->setExpectedExceptionRegExp(\FooException::class, '/foo.*$/', 123);
+
         ccc();
     }
 }

+ 2 - 0
tests/Fixtures/Integration/set/@PHPUnit52Migration-risky.test-out.php

@@ -25,6 +25,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
         $this->expectException(\FooException::class);
         $this->expectExceptionMessage(null);
         $this->expectExceptionCode(123);
+
         bbb();
     }
 
@@ -34,6 +35,7 @@ class FooTest extends \PHPUnit\Framework\TestCase {
     function test_php_unit_no_expectation_annotation_43()
     {
         $this->setExpectedExceptionRegExp(\FooException::class, '/foo.*$/', 123);
+
         ccc();
     }
 

Some files were not shown because too many files changed in this diff