4
4
*
5
5
* @author Kacper Pruszynski (plumthedev)
6
6
* @link https://github.com/plumthedev/yii2-php-cs-fixer-config
7
- * @copyright Copyright (c) 2019 plumthedev
7
+ * @copyright Copyright (c) 2019 - 2019 plumthedev
8
8
* @license https://github.com/plumthedev/yii2-php-cs-fixer-config/blob/master/LICENSE
9
9
* @version 1.0.1
10
10
*/
13
13
14
14
use PHPUnit_Framework_TestCase as TestCase ;
15
15
use plumthedev \PhpCsFixer \Finder ;
16
+ use ReflectionClass ;
17
+ use yii \base \InvalidArgumentException ;
16
18
17
19
class FinderTest extends TestCase
18
20
{
@@ -30,6 +32,52 @@ public function testIsInstanceOfPhpCsFixerFinder()
30
32
31
33
public function testIsExcludingDirs ()
32
34
{
33
- $ this ->assertNotEmpty ($ this ->csFixerFinder ->yiiProjectExcludePaths );
35
+ $ this ->assertNotEmpty ($ this ->csFixerFinder ->yiiAppExclude );
36
+ }
37
+
38
+ public function testIsExcludingYiiAppBasicDirs ()
39
+ {
40
+ $ getYiiAppBasicExcludeMethod = self ::getMethod ('getYiiAppBasicExclude ' );
41
+ $ yiiAppBasicExclude = $ getYiiAppBasicExcludeMethod ->invoke ($ this ->csFixerFinder );
42
+ foreach ($ yiiAppBasicExclude as $ exclude ) {
43
+ $ this ->assertContains ($ exclude , $ this ->csFixerFinder ->getYiiAppExclude ());
44
+ }
45
+ }
46
+
47
+ public function testIsExcludingYiiAppAdvancedDirs ()
48
+ {
49
+ $ getYiiAppAdvancedExcludeMethod = self ::getMethod ('getYiiAppAdvancedExclude ' );
50
+ $ yiiAppAdvancedExclude = $ getYiiAppAdvancedExcludeMethod ->invoke ($ this ->csFixerFinder );
51
+ foreach ($ yiiAppAdvancedExclude as $ exclude ) {
52
+ $ this ->assertContains ($ exclude , $ this ->csFixerFinder ->getYiiAppExclude ());
53
+ }
54
+ }
55
+
56
+ public function testExceptionOnNotArraySetter ()
57
+ {
58
+ $ this ->setExpectedException (InvalidArgumentException::class);
59
+ $ this ->csFixerFinder ->setYiiAppExclude ('notArray ' );
60
+ }
61
+
62
+ public function testIsMergingWithDefault ()
63
+ {
64
+ $ this ->csFixerFinder ->setYiiAppExclude (['mergeWithDef ' ]);
65
+ $ this ->assertContains ('mergeWithDef ' , $ this ->csFixerFinder ->getYiiAppExclude ());
66
+ $ this ->testIsExcludingYiiAppAdvancedDirs ();
67
+ $ this ->testIsExcludingYiiAppBasicDirs ();
68
+ }
69
+
70
+ public function testIsNotMergingWitHDefault ()
71
+ {
72
+ $ this ->csFixerFinder ->setYiiAppExclude (['mergeWithDef ' ], false );
73
+ $ this ->assertCount (1 , $ this ->csFixerFinder ->getYiiAppExclude ());
74
+ }
75
+
76
+ protected static function getMethod ($ name )
77
+ {
78
+ $ class = new ReflectionClass ('plumthedev\PhpCsFixer\Finder ' );
79
+ $ method = $ class ->getMethod ($ name );
80
+ $ method ->setAccessible (true );
81
+ return $ method ;
34
82
}
35
83
}
0 commit comments