Skip to content

Commit 95424f1

Browse files
committed
MAGETWO-95628: Filesystem Directory Improvement
1 parent af5544f commit 95424f1

File tree

3 files changed

+87
-4
lines changed

3 files changed

+87
-4
lines changed

dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/ReadTest.php

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public function testGetAbsolutePath()
3535
$this->assertContains('_files/foo/bar', $dir->getAbsolutePath('bar'));
3636
}
3737

38+
/**
39+
* @return void
40+
*/
3841
public function testGetAbsolutePathOutside()
3942
{
4043
$exceptions = 0;
@@ -54,6 +57,7 @@ public function testGetAbsolutePathOutside()
5457
} catch (ValidatorException $exception) {
5558
$exceptions++;
5659
}
60+
5761
$this->assertEquals(3, $exceptions);
5862
}
5963

@@ -68,6 +72,9 @@ public function testGetRelativePath()
6872
$this->assertEquals('bar', $dir->getRelativePath(__DIR__ . '/../_files/foo/bar'));
6973
}
7074

75+
/**
76+
* @return void
77+
*/
7178
public function testGetRelativePathOutside()
7279
{
7380
$exceptions = 0;
@@ -92,6 +99,7 @@ public function testGetRelativePathOutside()
9299
} catch (ValidatorException $exception) {
93100
$exceptions++;
94101
}
102+
95103
$this->assertEquals(4, $exceptions);
96104
}
97105

@@ -126,6 +134,9 @@ public function readProvider()
126134
];
127135
}
128136

137+
/**
138+
* @return void
139+
*/
129140
public function testReadOutside()
130141
{
131142
$exceptions = 0;
@@ -145,6 +156,7 @@ public function testReadOutside()
145156
} catch (ValidatorException $exception) {
146157
$exceptions++;
147158
}
159+
148160
$this->assertEquals(3, $exceptions);
149161
}
150162

@@ -179,6 +191,9 @@ public function searchProvider()
179191
];
180192
}
181193

194+
/**
195+
* @return void
196+
*/
182197
public function testSearchOutside()
183198
{
184199
$exceptions = 0;
@@ -198,6 +213,7 @@ public function testSearchOutside()
198213
} catch (ValidatorException $exception) {
199214
$exceptions++;
200215
}
216+
201217
$this->assertEquals(3, $exceptions);
202218
}
203219

@@ -225,6 +241,9 @@ public function existsProvider()
225241
return [['foo', 'bar', true], ['foo', 'bar/baz/', true], ['foo', 'bar/notexists', false]];
226242
}
227243

244+
/**
245+
* @return void
246+
*/
228247
public function testIsExistOutside()
229248
{
230249
$exceptions = 0;
@@ -244,6 +263,7 @@ public function testIsExistOutside()
244263
} catch (ValidatorException $exception) {
245264
$exceptions++;
246265
}
266+
247267
$this->assertEquals(3, $exceptions);
248268
}
249269

@@ -288,6 +308,9 @@ public function statProvider()
288308
return [['foo', 'bar'], ['foo', 'file_three.txt']];
289309
}
290310

311+
/**
312+
* @return void
313+
*/
291314
public function testStatOutside()
292315
{
293316
$exceptions = 0;
@@ -307,6 +330,7 @@ public function testStatOutside()
307330
} catch (ValidatorException $exception) {
308331
$exceptions++;
309332
}
333+
310334
$this->assertEquals(3, $exceptions);
311335
}
312336

@@ -324,6 +348,9 @@ public function testIsReadable($dirPath, $path, $readable)
324348
$this->assertEquals($readable, $dir->isReadable($path));
325349
}
326350

351+
/**
352+
* @return void
353+
*/
327354
public function testIsReadableOutside()
328355
{
329356
$exceptions = 0;
@@ -343,6 +370,7 @@ public function testIsReadableOutside()
343370
} catch (ValidatorException $exception) {
344371
$exceptions++;
345372
}
373+
346374
$this->assertEquals(3, $exceptions);
347375
}
348376

@@ -358,6 +386,9 @@ public function testIsFile($path, $isFile)
358386
$this->assertEquals($isFile, $this->getDirectoryInstance('foo')->isFile($path));
359387
}
360388

389+
/**
390+
* @return void
391+
*/
361392
public function testIsFileOutside()
362393
{
363394
$exceptions = 0;
@@ -377,6 +408,7 @@ public function testIsFileOutside()
377408
} catch (ValidatorException $exception) {
378409
$exceptions++;
379410
}
411+
380412
$this->assertEquals(3, $exceptions);
381413
}
382414

@@ -392,6 +424,9 @@ public function testIsDirectory($path, $isDirectory)
392424
$this->assertEquals($isDirectory, $this->getDirectoryInstance('foo')->isDirectory($path));
393425
}
394426

427+
/**
428+
* @return void
429+
*/
395430
public function testIsDirectoryOutside()
396431
{
397432
$exceptions = 0;
@@ -411,6 +446,7 @@ public function testIsDirectoryOutside()
411446
} catch (ValidatorException $exception) {
412447
$exceptions++;
413448
}
449+
414450
$this->assertEquals(3, $exceptions);
415451
}
416452

@@ -454,6 +490,9 @@ public function testOpenFile()
454490
$this->assertTrue($file instanceof \Magento\Framework\Filesystem\File\ReadInterface);
455491
}
456492

493+
/**
494+
* @return void
495+
*/
457496
public function testOpenFileOutside()
458497
{
459498
$exceptions = 0;
@@ -473,6 +512,7 @@ public function testOpenFileOutside()
473512
} catch (ValidatorException $exception) {
474513
$exceptions++;
475514
}
515+
476516
$this->assertEquals(3, $exceptions);
477517
}
478518

@@ -500,11 +540,14 @@ public function readFileProvider()
500540
['popup.csv', 'var myData = 5;'],
501541
[
502542
'data.csv',
503-
'"field1", "field2"' . PHP_EOL . '"field3", "field4"' . PHP_EOL
504-
]
543+
'"field1", "field2"' . PHP_EOL . '"field3", "field4"' . PHP_EOL,
544+
],
505545
];
506546
}
507547

548+
/**
549+
* @return void
550+
*/
508551
public function testReadFileOutside()
509552
{
510553
$exceptions = 0;
@@ -524,6 +567,7 @@ public function testReadFileOutside()
524567
} catch (ValidatorException $exception) {
525568
$exceptions++;
526569
}
570+
527571
$this->assertEquals(3, $exceptions);
528572
}
529573

@@ -557,6 +601,9 @@ public function testReadRecursively()
557601
$this->assertEquals($expected, $actual);
558602
}
559603

604+
/**
605+
* @return void
606+
*/
560607
public function testReadRecursivelyOutside()
561608
{
562609
$exceptions = 0;
@@ -576,6 +623,7 @@ public function testReadRecursivelyOutside()
576623
} catch (ValidatorException $exception) {
577624
$exceptions++;
578625
}
626+
579627
$this->assertEquals(3, $exceptions);
580628
}
581629
}

dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/WriteTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function createProvider()
6464
];
6565
}
6666

67+
/**
68+
* @return void
69+
*/
6770
public function testCreateOutside()
6871
{
6972
$exceptions = 0;
@@ -83,6 +86,7 @@ public function testCreateOutside()
8386
} catch (ValidatorException $exception) {
8487
$exceptions++;
8588
}
89+
8690
$this->assertEquals(3, $exceptions);
8791
}
8892

@@ -111,6 +115,9 @@ public function deleteProvider()
111115
return [['subdir'], ['subdir/subsubdir']];
112116
}
113117

118+
/**
119+
* @return void
120+
*/
114121
public function testDeleteOutside()
115122
{
116123
$exceptions = 0;
@@ -130,6 +137,7 @@ public function testDeleteOutside()
130137
} catch (ValidatorException $exception) {
131138
$exceptions++;
132139
}
140+
133141
$this->assertEquals(3, $exceptions);
134142
}
135143

@@ -164,6 +172,9 @@ public function renameProvider()
164172
return [['newDir1', 0777, 'first_name.txt', 'second_name.txt']];
165173
}
166174

175+
/**
176+
* @return void
177+
*/
167178
public function testRenameOutside()
168179
{
169180
$exceptions = 0;
@@ -186,6 +197,7 @@ public function testRenameOutside()
186197
} catch (ValidatorException $exception) {
187198
$exceptions++;
188199
}
200+
189201
$this->assertEquals(3, $exceptions);
190202
}
191203

@@ -255,6 +267,9 @@ public function copyProvider()
255267
];
256268
}
257269

270+
/**
271+
* @return void
272+
*/
258273
public function testCopyOutside()
259274
{
260275
$exceptions = 0;
@@ -286,6 +301,7 @@ public function testCopyOutside()
286301
} catch (ValidatorException $exception) {
287302
$exceptions++;
288303
}
304+
289305
$this->assertEquals(4, $exceptions);
290306
}
291307

@@ -335,6 +351,9 @@ public function testChangePermissions()
335351
$this->assertTrue($directory->changePermissions('test_directory', 0644));
336352
}
337353

354+
/**
355+
* @return void
356+
*/
338357
public function testChangePermissionsOutside()
339358
{
340359
$exceptions = 0;
@@ -354,6 +373,7 @@ public function testChangePermissionsOutside()
354373
} catch (ValidatorException $exception) {
355374
$exceptions++;
356375
}
376+
357377
$this->assertEquals(3, $exceptions);
358378
}
359379

@@ -370,6 +390,9 @@ public function testChangePermissionsRecursively()
370390
$this->assertTrue($directory->changePermissionsRecursively('test_directory', 0777, 0644));
371391
}
372392

393+
/**
394+
* @return void
395+
*/
373396
public function testChangePermissionsRecursivelyOutside()
374397
{
375398
$exceptions = 0;
@@ -389,6 +412,7 @@ public function testChangePermissionsRecursivelyOutside()
389412
} catch (ValidatorException $exception) {
390413
$exceptions++;
391414
}
415+
392416
$this->assertEquals(3, $exceptions);
393417
}
394418

@@ -422,6 +446,9 @@ public function touchProvider()
422446
];
423447
}
424448

449+
/**
450+
* @return void
451+
*/
425452
public function testTouchOutside()
426453
{
427454
$exceptions = 0;
@@ -441,6 +468,7 @@ public function testTouchOutside()
441468
} catch (ValidatorException $exception) {
442469
$exceptions++;
443470
}
471+
444472
$this->assertEquals(3, $exceptions);
445473
}
446474

@@ -507,6 +535,9 @@ public function openFileProvider()
507535
];
508536
}
509537

538+
/**
539+
* @return void
540+
*/
510541
public function testOpenFileOutside()
511542
{
512543
$exceptions = 0;
@@ -526,6 +557,7 @@ public function testOpenFileOutside()
526557
} catch (ValidatorException $exception) {
527558
$exceptions++;
528559
}
560+
529561
$this->assertEquals(3, $exceptions);
530562
}
531563

@@ -573,6 +605,9 @@ public function writeFileProvider()
573605
return [['file1', '123', '456'], ['folder1/file1', '123', '456']];
574606
}
575607

608+
/**
609+
* @return void
610+
*/
576611
public function testWriteFileOutside()
577612
{
578613
$exceptions = 0;
@@ -592,6 +627,7 @@ public function testWriteFileOutside()
592627
} catch (ValidatorException $exception) {
593628
$exceptions++;
594629
}
630+
595631
$this->assertEquals(3, $exceptions);
596632
}
597633

0 commit comments

Comments
 (0)