Browse Source

DX: extend integration tests for PSR2 and Symfony rulesets

Dariusz Ruminski 8 years ago
parent
commit
e00b7c6d02

+ 4 - 10
src/Test/IntegrationCaseFactory.php

@@ -122,7 +122,7 @@ final class IntegrationCaseFactory
 
     protected function determineExpectedCode($code, $file)
     {
-        $code = $this->determineCode($code, $file, '.out');
+        $code = $this->determineCode($code, $file, '-out.php');
 
         if (null === $code) {
             throw new \InvalidArgumentException('Missing expected code.');
@@ -133,22 +133,16 @@ final class IntegrationCaseFactory
 
     protected function determineInputCode($code, $file)
     {
-        return $this->determineCode($code, $file, '.in');
+        return $this->determineCode($code, $file, '-in.php');
     }
 
-    private function determineCode($code, $file, $newExtension)
+    private function determineCode($code, $file, $suffix)
     {
         if (null !== $code) {
             return $code;
         }
 
-        $candidatePath = sprintf(
-            '%s%s%s%s',
-            $file->getPath(),
-            DIRECTORY_SEPARATOR,
-            $file->getBasename('.test'),
-            $newExtension
-        );
+        $candidatePath = $file->getPathname().$suffix;
 
         $candidateFile = new SplFileInfo($candidatePath, '', '');
         if ($candidateFile->isFile()) {

+ 0 - 50
tests/Fixtures/Integration/set/@PSR2.test

@@ -4,53 +4,3 @@ Integration of @PSR2.
 {"@PSR2": true}
 --SETTINGS--
 {"checkPriority": false}
---EXPECT--
-<?php
-namespace Vendor\Package;
-
-use FooInterface;
-use BarClass as Bar;
-use OtherVendor\OtherPackage\BazClass;
-
-class Foo extends Bar implements FooInterface
-{
-    public function sampleFunction($a, $b = null)
-    {
-        if ($a === $b) {
-            bar();
-        } elseif ($a > $b) {
-            $foo->bar($arg1);
-        } else {
-            BazClass::bar($arg2, $arg3);
-        }
-    }
-
-    final public static function bar()
-    {
-        // method body
-    }
-}
-
---INPUT--
-<?
-namespace Vendor\Package;
-use FooInterface;
-use BarClass as Bar;
-use OtherVendor\OtherPackage\BazClass;
-class Foo extends Bar implements FooInterface{
-    public function sampleFunction($a, $b = null)
-    {
-        if ($a === $b) {
-            bar();
-        } else if ($a > $b) {
-            $foo->bar($arg1);
-        } else {
-                BazClass::bar($arg2, $arg3);
-        }
-    }
-
-    static public  final function bar() {
-    // method body
-    }
-}
-?>

+ 30 - 0
tests/Fixtures/Integration/set/@PSR2.test-in.php

@@ -0,0 +1,30 @@
+<?
+namespace Vendor\Package;
+use FooInterface, FooInterfaceB;
+use BarClass as Bar;
+use OtherVendor\OtherPackage\BazClass;
+class Foo extends Bar implements FooInterface{
+    var $aaa = 1, $bbb = 2;
+
+    public function sampleFunction($a, $b = null)
+    {
+        if ($a === $b) {
+            bar();
+        } else if ($a > $b) {
+            $foo->bar($arg1);
+        } else {
+                BazClass::bar($arg2, $arg3);
+        }
+    }
+
+    static public  final function bar() {
+    // method body
+    }
+}
+
+class Aaa implements
+    Bbb, Ccc,
+    Ddd
+    {
+    }
+?>

+ 36 - 0
tests/Fixtures/Integration/set/@PSR2.test-out.php

@@ -0,0 +1,36 @@
+<?php
+namespace Vendor\Package;
+
+use FooInterface;
+use FooInterfaceB;
+use BarClass as Bar;
+use OtherVendor\OtherPackage\BazClass;
+
+class Foo extends Bar implements FooInterface
+{
+    public $aaa = 1;
+    public $bbb = 2;
+
+    public function sampleFunction($a, $b = null)
+    {
+        if ($a === $b) {
+            bar();
+        } elseif ($a > $b) {
+            $foo->bar($arg1);
+        } else {
+            BazClass::bar($arg2, $arg3);
+        }
+    }
+
+    final public static function bar()
+    {
+        // method body
+    }
+}
+
+class Aaa implements
+    Bbb,
+Ccc,
+    Ddd
+{
+}

+ 0 - 80
tests/Fixtures/Integration/set/@Symfony.test

@@ -4,83 +4,3 @@ Integration of @Symfony.
 {"@Symfony": true}
 --SETTINGS--
 {"checkPriority": false}
---EXPECT--
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Acme;
-
-declare(ticks=1);
-
-/**
- * Coding standards demonstration.
- */
-class FooBar
-{
-    const SOME_CONST = 42;
-
-    private $fooBar;
-
-    /**
-     * @param string $dummy Some argument description
-     */
-    public function __construct($dummy)
-    {
-        $this->fooBar = $this->transformText($dummy);
-    }
-
-    /**
-     * @param string $dummy   Some argument description
-     * @param array  $options
-     *
-     * @return string|null Transformed input
-     *
-     * @throws \RuntimeException
-     */
-    private function transformText($dummy, array $options = array())
-    {
-        $mergedOptions = array_merge(
-            array(
-                'some_default' => 'values',
-                'another_default' => 'more values',
-            ),
-            $options
-        );
-
-        if (true === $dummy) {
-            return;
-        }
-
-        if ('string' === $dummy) {
-            if ('values' === $mergedOptions['some_default']) {
-                return substr($dummy, 0, 5);
-            }
-
-            return ucwords($dummy);
-        }
-
-        throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
-    }
-
-    private function reverseBoolean($value = null, $theSwitch = false)
-    {
-        if (!$theSwitch) {
-            return;
-        }
-
-        return !$value;
-    }
-
-    private function printText($text)
-    {
-        echo $text;
-    }
-}

+ 86 - 0
tests/Fixtures/Integration/set/@Symfony.test-in.php

@@ -0,0 +1,86 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Acme;
+
+declare(ticks=1);
+
+/**
+ * Coding standards demonstration.
+ */
+class FooBar
+{
+
+
+    const SOME_CONST = 42;
+
+    private $fooBar;
+
+    /**
+     * @param string $dummy Some argument description
+     */
+    public function __construct($dummy)
+    {
+        $this->fooBar = $this->transformText($dummy);
+    }
+
+    /**
+     * Foo
+     * @param string $dummy Some argument description
+     * @param array $options
+     * @param string|null $data Foo
+     *
+     * @return string|null Transformed input
+     *
+     * @throws \RuntimeException
+     */
+    private function transformText($dummy, array $options = array(),$data=null)
+    {
+        $mergedOptions = array_merge(
+            array(
+                'some_default' => 'values',
+                'another_default' => 'more values',
+            ),
+            $options
+        );
+
+        if (true === $dummy) {
+            return;
+        }
+
+        if ('string' === $dummy) {
+            if ('values' === $mergedOptions['some_default']) {
+                return substr($dummy, 0, 5);
+            }
+            return ucwords($dummy);
+        }
+
+        throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
+    }
+    private function reverseBoolean($value = null, $theSwitch = false)
+    {
+        if (!$theSwitch) {
+            return;
+        }
+
+        return !$value;
+    }
+
+
+    /**
+     * @param string $text
+     * @return string
+     */
+    private function printText($text)
+    {
+        echo $text;
+    }
+}

+ 87 - 0
tests/Fixtures/Integration/set/@Symfony.test-out.php

@@ -0,0 +1,87 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Acme;
+
+declare(ticks=1);
+
+/**
+ * Coding standards demonstration.
+ */
+class FooBar
+{
+    const SOME_CONST = 42;
+
+    private $fooBar;
+
+    /**
+     * @param string $dummy Some argument description
+     */
+    public function __construct($dummy)
+    {
+        $this->fooBar = $this->transformText($dummy);
+    }
+
+    /**
+     * Foo.
+     *
+     * @param string      $dummy   Some argument description
+     * @param array       $options
+     * @param string|null $data    Foo
+     *
+     * @return string|null Transformed input
+     *
+     * @throws \RuntimeException
+     */
+    private function transformText($dummy, array $options = array(), $data = null)
+    {
+        $mergedOptions = array_merge(
+            array(
+                'some_default' => 'values',
+                'another_default' => 'more values',
+            ),
+            $options
+        );
+
+        if (true === $dummy) {
+            return;
+        }
+
+        if ('string' === $dummy) {
+            if ('values' === $mergedOptions['some_default']) {
+                return substr($dummy, 0, 5);
+            }
+
+            return ucwords($dummy);
+        }
+
+        throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
+    }
+
+    private function reverseBoolean($value = null, $theSwitch = false)
+    {
+        if (!$theSwitch) {
+            return;
+        }
+
+        return !$value;
+    }
+
+    /**
+     * @param string $text
+     *
+     * @return string
+     */
+    private function printText($text)
+    {
+        echo $text;
+    }
+}