@@ -140,6 +140,46 @@ public function testWriteMessagesForSpecificDomain()
140
140
$ this ->assertMatchesRegularExpression ('/Translation files were successfully updated./ ' , $ tester ->getDisplay ());
141
141
}
142
142
143
+ public function testFilterDuplicateTransPaths ()
144
+ {
145
+ $ transPaths = [
146
+ $ this ->translationDir .'/a/test/folder/with/a/subfolder ' ,
147
+ $ this ->translationDir .'/a/test/folder/ ' ,
148
+ $ this ->translationDir .'/a/test/folder/with/a/subfolder/and/a/file.txt ' ,
149
+ $ this ->translationDir .'/a/different/test/folder ' ,
150
+ ];
151
+
152
+ foreach ($ transPaths as $ transPath ) {
153
+ if (realpath ($ transPath )) {
154
+ continue ;
155
+ }
156
+
157
+ if (preg_match ('/\.[a-z]+$/ ' , $ transPath )) {
158
+ if (!realpath (dirname ($ transPath ))) {
159
+ mkdir (dirname ($ transPath ), 0777 , true );
160
+ }
161
+
162
+ touch ($ transPath );
163
+ } else {
164
+ mkdir ($ transPath , 0777 , true );
165
+ }
166
+ }
167
+
168
+ $ expectedPaths = [
169
+ $ this ->translationDir .'/a/different/test/folder ' ,
170
+ $ this ->translationDir .'/a/test/folder ' ,
171
+ ];
172
+
173
+ $ command = $ this ->createMock (TranslationUpdateCommand::class);
174
+
175
+ $ method = new \ReflectionMethod (TranslationUpdateCommand::class, 'filterDuplicateTransPaths ' );
176
+ $ method ->setAccessible (true );
177
+
178
+ $ filteredTransPaths = $ method ->invoke ($ command , $ transPaths );
179
+
180
+ $ this ->assertEquals ($ expectedPaths , $ filteredTransPaths );
181
+ }
182
+
143
183
protected function setUp (): void
144
184
{
145
185
$ this ->fs = new Filesystem ();
0 commit comments