Browse Source

Merge branch '2.2'

# Conflicts:
#	src/WhitespacesFixerConfig.php
#	tests/WhitespacesFixerConfigTest.php
Dariusz Ruminski 7 years ago
parent
commit
582025e89d
2 changed files with 10 additions and 7 deletions
  1. 2 2
      src/WhitespacesFixerConfig.php
  2. 8 5
      tests/WhitespacesFixerConfigTest.php

+ 2 - 2
src/WhitespacesFixerConfig.php

@@ -27,11 +27,11 @@ final class WhitespacesFixerConfig
     public function __construct($indent = '    ', $lineEnding = "\n")
     {
         if (!in_array($indent, ['  ', '    ', "\t"], true)) {
-            throw new \InvalidArgumentException('Invalid "indent" param.');
+            throw new \InvalidArgumentException('Invalid "indent" param, expected tab or two or four spaces.');
         }
 
         if (!in_array($lineEnding, ["\n", "\r\n"], true)) {
-            throw new \InvalidArgumentException('Invalid "lineEnding" param.');
+            throw new \InvalidArgumentException('Invalid "lineEnding" param, expected "\n" or "\r\n".');
         }
 
         $this->indent = $indent;

+ 8 - 5
tests/WhitespacesFixerConfigTest.php

@@ -34,7 +34,10 @@ final class WhitespacesFixerConfigTest extends TestCase
     public function testCases($indent, $lineEnding, $exceptionRegExp = null)
     {
         if (null !== $exceptionRegExp) {
-            $this->setExpectedExceptionRegExp(\InvalidArgumentException::class, $exceptionRegExp);
+            $this->setExpectedExceptionRegExp(
+                \InvalidArgumentException::class,
+                '%^'.preg_quote($exceptionRegExp, '%').'$%'
+            );
         }
 
         $config = new WhitespacesFixerConfig($indent, $lineEnding);
@@ -50,10 +53,10 @@ final class WhitespacesFixerConfigTest extends TestCase
             ["\t", "\n"],
             ['    ', "\r\n"],
             ["\t", "\r\n"],
-            ['    ', 'asd', '/lineEnding/'],
-            ['    ', [], '/lineEnding/'],
-            ['std', "\n", '/indent/'],
-            [[], "\n", '/indent/'],
+            ['    ', 'asd', 'Invalid "lineEnding" param, expected "\n" or "\r\n".'],
+            ['    ', [], 'Invalid "lineEnding" param, expected "\n" or "\r\n".'],
+            ['std', "\n", 'Invalid "indent" param, expected tab or two or four spaces.'],
+            [[], "\n", 'Invalid "indent" param, expected tab or two or four spaces.'],
         ];
     }
 }