Browse Source

Merge branch '2.2'

# Conflicts:
#	tests/Fixer/DoctrineAnnotation/DoctrineAnnotationBracesFixerTest.php
#	tests/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixerTest.php
#	tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php
Dariusz Ruminski 7 years ago
parent
commit
0cd8f38815

+ 31 - 15
tests/AbstractDoctrineAnnotationFixerTestCase.php

@@ -45,17 +45,35 @@ abstract class AbstractDoctrineAnnotationFixerTestCase extends AbstractFixerTest
     }
 
     /**
-     * {@inheritdoc}
+     * @param array<array<string>> $commentCases
+     *
+     * @return array
      */
-    protected function doTest($expected, $input = null, \SplFileInfo $file = null)
+    protected function createTestCases(array $commentCases)
     {
-        parent::doTest($this->withClassDocBlock($expected), $this->withClassDocBlock($input), $file);
-
-        parent::doTest($this->withPropertyDocBlock($expected), $this->withPropertyDocBlock($input), $file);
-
-        parent::doTest($this->withMethodDocBlock($expected), $this->withMethodDocBlock($input), $file);
+        $cases = [];
+        foreach ($commentCases as $commentCase) {
+            $cases[] = [
+                $this->withClassDocBlock($commentCase[0]),
+                isset($commentCase[1]) ? $this->withClassDocBlock($commentCase[1]) : null,
+            ];
+
+            $cases[] = [
+                $this->withPropertyDocBlock($commentCase[0]),
+                isset($commentCase[1]) ? $this->withPropertyDocBlock($commentCase[1]) : null,
+            ];
+
+            $cases[] = [
+                $this->withMethodDocBlock($commentCase[0]),
+                isset($commentCase[1]) ? $this->withMethodDocBlock($commentCase[1]) : null,
+            ];
+
+            $cases[] = [
+                $this->withWrongElementDocBlock($commentCase[0]),
+            ];
+        }
 
-        parent::doTest($this->withWrongElementDocBlock($expected), null, $file);
+        return $cases;
     }
 
     /**
@@ -121,17 +139,15 @@ $foo = bar();', $comment, false);
     }
 
     /**
-     * @param string      $php
-     * @param string|null $comment
-     * @param bool        $indent
+     * @param string $php
+     * @param string $comment
+     * @param bool   $indent
      *
-     * @return string|null
+     * @return string
      */
     private function with($php, $comment, $indent)
     {
-        if (null === $comment) {
-            return null;
-        }
+        $comment = trim($comment);
 
         if ($indent) {
             $comment = str_replace("\n", "\n    ", $comment);

+ 4 - 4
tests/Fixer/DoctrineAnnotation/DoctrineAnnotationBracesFixerTest.php

@@ -39,7 +39,7 @@ final class DoctrineAnnotationBracesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixWithBracesCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo()
@@ -261,7 +261,7 @@ final class DoctrineAnnotationBracesFixerTest extends AbstractDoctrineAnnotation
  * @override
  * @todo: foo
  */'],
-        ];
+        ]);
     }
 
     /**
@@ -283,7 +283,7 @@ final class DoctrineAnnotationBracesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixWithoutBracesCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * Foo.
@@ -522,7 +522,7 @@ final class DoctrineAnnotationBracesFixerTest extends AbstractDoctrineAnnotation
  * @override()
  * @todo: foo()
  */'],
-        ];
+        ]);
     }
 
     /**

+ 2 - 2
tests/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixerTest.php

@@ -38,7 +38,7 @@ final class DoctrineAnnotationIndentationFixerTest extends AbstractDoctrineAnnot
      */
     public function getFixCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * Foo.
@@ -266,6 +266,6 @@ final class DoctrineAnnotationIndentationFixerTest extends AbstractDoctrineAnnot
  *     @fixme
  *     @override
  */'],
-        ];
+        ]);
     }
 }

+ 11 - 10
tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php

@@ -46,7 +46,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixAllCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo
@@ -301,8 +301,9 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
             ['
 /**
  * @Transform /^(\d+)$/
+
  */'],
-        ];
+        ]);
     }
 
     /**
@@ -334,7 +335,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixAroundParenthesesOnlyCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo
@@ -541,7 +542,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
  * @fixme ( foo,bar  =  "baz" )
  * @override
  */'],
-        ];
+        ]);
     }
 
     /**
@@ -573,7 +574,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixAroundCommasOnlyCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo
@@ -803,7 +804,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
  * @fixme ( foo,bar  =  "baz" )
  * @override
  */'],
-        ];
+        ]);
     }
 
     /**
@@ -835,7 +836,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixAroundArgumentAssignmentsOnlyCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo (foo="foo", bar="bar")
@@ -1057,7 +1058,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
  * @fixme ( foo,bar  =  "baz" )
  * @override
  */'],
-        ];
+        ]);
     }
 
     /**
@@ -1089,7 +1090,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
      */
     public function getFixAroundArrayAssignmentsOnlyCases()
     {
-        return [
+        return $this->createTestCases([
             ['
 /**
  * @Foo (foo="foo", bar="bar")
@@ -1291,7 +1292,7 @@ final class DoctrineAnnotationSpacesFixerTest extends AbstractDoctrineAnnotation
  * @fixme ( foo,bar  =  "baz" )
  * @override
  */'],
-        ];
+        ]);
     }
 
     /**