File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ public function createFinder(string $in)
127
127
128
128
public function isPathInVendor (string $ path ): bool
129
129
{
130
- return 0 === strpos ($ path , $ this ->rootDirectory .'/vendor/ ' );
130
+ return 0 === strpos ($ this -> normalizeSlashes ( $ path) , $ this ->normalizeSlashes ( $ this -> rootDirectory .'/vendor/ ' ) );
131
131
}
132
132
133
133
public function absolutizePath ($ path ): string
Original file line number Diff line number Diff line change @@ -87,4 +87,46 @@ public function getAbsolutePathTests()
87
87
'D:/foo/bar ' ,
88
88
];
89
89
}
90
+
91
+ /**
92
+ * @dataProvider getIsPathInVendorTests
93
+ */
94
+ public function testIsPathInVendor (string $ rootDir , string $ path , bool $ expectedIsInVendor )
95
+ {
96
+ $ fileManager = new FileManager (new Filesystem (), $ this ->createMock (AutoloaderUtil::class), $ rootDir );
97
+ $ this ->assertSame ($ expectedIsInVendor , $ fileManager ->isPathInVendor ($ path ));
98
+ }
99
+
100
+ public function getIsPathInVendorTests ()
101
+ {
102
+ yield 'not_in_vendor ' => [
103
+ '/home/project/ ' ,
104
+ '/home/project/foo/bar ' ,
105
+ false ,
106
+ ];
107
+
108
+ yield 'in_vendor ' => [
109
+ '/home/project/ ' ,
110
+ '/home/project/vendor/foo ' ,
111
+ true ,
112
+ ];
113
+
114
+ yield 'not_in_this_vendor ' => [
115
+ '/home/project/ ' ,
116
+ '/other/path/vendor/foo ' ,
117
+ false ,
118
+ ];
119
+
120
+ yield 'windows_not_in_vendor ' => [
121
+ 'D:\path\to\project ' ,
122
+ 'D:\path\to\project\src\foo ' ,
123
+ false ,
124
+ ];
125
+
126
+ yield 'windows_in_vendor ' => [
127
+ 'D:\path\to\project ' ,
128
+ 'D:\path\to\project\vendor\foo ' ,
129
+ true ,
130
+ ];
131
+ }
90
132
}
You can’t perform that action at this time.
0 commit comments