7
7
8
8
namespace Icewind \SMB \Test ;
9
9
10
+ use Icewind \SMB \Exception \AlreadyExistsException ;
10
11
use Icewind \SMB \Exception \FileInUseException ;
11
12
use Icewind \SMB \Exception \InvalidPathException ;
13
+ use Icewind \SMB \Exception \InvalidResourceException ;
14
+ use Icewind \SMB \Exception \InvalidTypeException ;
15
+ use Icewind \SMB \Exception \NotEmptyException ;
12
16
use Icewind \SMB \Exception \NotFoundException ;
13
17
use Icewind \SMB \FileInfo ;
14
18
use Icewind \SMB \IFileInfo ;
@@ -32,7 +36,7 @@ abstract class AbstractShareTest extends TestCase {
32
36
33
37
protected $ config ;
34
38
35
- public function tearDown () {
39
+ public function tearDown (): void {
36
40
try {
37
41
if ($ this ->share ) {
38
42
try {
@@ -142,9 +146,9 @@ public function testMkdir($name) {
142
146
143
147
/**
144
148
* @dataProvider invalidPathProvider
145
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
146
149
*/
147
150
public function testMkdirInvalidPath ($ name ) {
151
+ $ this ->expectException (InvalidPathException::class);
148
152
$ this ->share ->mkdir ($ this ->root . '/ ' . $ name );
149
153
$ dirs = $ this ->share ->dir ($ this ->root );
150
154
$ this ->assertCount (1 , $ dirs );
@@ -191,9 +195,9 @@ public function testPut($name, $text) {
191
195
192
196
/**
193
197
* @dataProvider invalidPathProvider
194
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
195
198
*/
196
199
public function testPutInvalidPath ($ name ) {
200
+ $ this ->expectException (InvalidPathException::class);
197
201
$ tmpFile = $ this ->getTextFile ('foo ' );
198
202
199
203
try {
@@ -237,10 +241,8 @@ public function testGet($name, $text) {
237
241
unlink ($ targetFile );
238
242
}
239
243
240
- /**
241
- * @expectedException \Icewind\SMB\Exception\InvalidResourceException
242
- */
243
244
public function testGetInvalidTarget () {
245
+ $ this ->expectException (InvalidResourceException::class);
244
246
$ name = 'test.txt ' ;
245
247
$ text = 'dummy ' ;
246
248
$ tmpFile = $ this ->getTextFile ($ text );
@@ -273,150 +275,120 @@ public function testNotFoundExceptionPath() {
273
275
}
274
276
}
275
277
276
- /**
277
- * @expectedException \Icewind\SMB\Exception\NotFoundException
278
- */
279
278
public function testCreateFolderInNonExistingFolder () {
279
+ $ this ->expectException (NotFoundException::class);
280
280
$ this ->share ->mkdir ($ this ->root . '/foo/bar ' );
281
281
}
282
282
283
- /**
284
- * @expectedException \Icewind\SMB\Exception\NotFoundException
285
- */
286
283
public function testRemoveFolderInNonExistingFolder () {
284
+ $ this ->expectException (NotFoundException::class);
287
285
$ this ->share ->rmdir ($ this ->root . '/foo/bar ' );
288
286
}
289
287
290
- /**
291
- * @expectedException \Icewind\SMB\Exception\NotFoundException
292
- */
293
288
public function testRemoveNonExistingFolder () {
289
+ $ this ->expectException (NotFoundException::class);
294
290
$ this ->share ->rmdir ($ this ->root . '/foo ' );
295
291
}
296
292
297
- /**
298
- * @expectedException \Icewind\SMB\Exception\AlreadyExistsException
299
- */
300
293
public function testCreateExistingFolder () {
294
+ $ this ->expectException (AlreadyExistsException::class);
301
295
$ this ->share ->mkdir ($ this ->root . '/bar ' );
302
296
$ this ->share ->mkdir ($ this ->root . '/bar ' );
303
297
$ this ->share ->rmdir ($ this ->root . '/bar ' );
304
298
}
305
299
306
- /**
307
- * @expectedException \Icewind\SMB\Exception\InvalidTypeException
308
- */
309
300
public function testCreateFileExistingFolder () {
301
+ $ this ->expectException (InvalidTypeException::class);
310
302
$ this ->share ->mkdir ($ this ->root . '/bar ' );
311
303
$ this ->share ->put ($ this ->getTextFile (), $ this ->root . '/bar ' );
312
304
$ this ->share ->rmdir ($ this ->root . '/bar ' );
313
305
}
314
306
315
- /**
316
- * @expectedException \Icewind\SMB\Exception\NotFoundException
317
- */
318
307
public function testCreateFileInNonExistingFolder () {
308
+ $ this ->expectException (NotFoundException::class);
319
309
$ this ->share ->put ($ this ->getTextFile (), $ this ->root . '/foo/bar ' );
320
310
}
321
311
322
- /**
323
- * @expectedException \Icewind\SMB\Exception\NotFoundException
324
- */
325
312
public function testTestRemoveNonExistingFile () {
313
+ $ this ->expectException (NotFoundException::class);
326
314
$ this ->share ->del ($ this ->root . '/foo ' );
327
315
}
328
316
329
317
/**
330
318
* @dataProvider invalidPathProvider
331
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
332
319
*/
333
320
public function testDownloadInvalidPath ($ name ) {
321
+ $ this ->expectException (InvalidPathException::class);
334
322
$ this ->share ->get ($ name , '' );
335
323
}
336
324
337
- /**
338
- * @expectedException \Icewind\SMB\Exception\NotFoundException
339
- */
340
325
public function testDownloadNonExistingFile () {
326
+ $ this ->expectException (NotFoundException::class);
341
327
$ this ->share ->get ($ this ->root . '/foo ' , '/dev/null ' );
342
328
}
343
329
344
- /**
345
- * @expectedException \Icewind\SMB\Exception\InvalidTypeException
346
- */
347
330
public function testDownloadFolder () {
331
+ $ this ->expectException (InvalidTypeException::class);
348
332
$ this ->share ->mkdir ($ this ->root . '/foobar ' );
349
333
$ this ->share ->get ($ this ->root . '/foobar ' , '/dev/null ' );
350
334
$ this ->share ->rmdir ($ this ->root . '/foobar ' );
351
335
}
352
336
353
337
/**
354
338
* @dataProvider invalidPathProvider
355
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
356
339
*/
357
340
public function testDelInvalidPath ($ name ) {
341
+ $ this ->expectException (InvalidPathException::class);
358
342
$ this ->share ->del ($ name );
359
343
}
360
344
361
- /**
362
- * @expectedException \Icewind\SMB\Exception\InvalidTypeException
363
- */
364
345
public function testRmdirFile () {
346
+ $ this ->expectException (InvalidTypeException::class);
365
347
$ this ->share ->put ($ this ->getTextFile (), $ this ->root . '/foobar ' );
366
348
$ this ->share ->rmdir ($ this ->root . '/foobar ' );
367
349
$ this ->share ->del ($ this ->root . '/foobar ' );
368
350
}
369
351
370
- /**
371
- * @expectedException \Icewind\SMB\Exception\NotEmptyException
372
- */
373
352
public function testRmdirNotEmpty () {
353
+ $ this ->expectException (NotEmptyException::class);
374
354
$ this ->share ->mkdir ($ this ->root . '/foobar ' );
375
355
$ this ->share ->put ($ this ->getTextFile (), $ this ->root . '/foobar/asd ' );
376
356
$ this ->share ->rmdir ($ this ->root . '/foobar ' );
377
357
}
378
358
379
359
/**
380
360
* @dataProvider invalidPathProvider
381
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
382
361
*/
383
362
public function testRmDirInvalidPath ($ name ) {
363
+ $ this ->expectException (InvalidPathException::class);
384
364
$ this ->share ->rmdir ($ name );
385
365
}
386
366
387
- /**
388
- * @expectedException \Icewind\SMB\Exception\NotFoundException
389
- */
390
367
public function testDirNonExisting () {
368
+ $ this ->expectException (NotFoundException::class);
391
369
$ this ->share ->dir ('/foobar/asd ' );
392
370
}
393
371
394
- /**
395
- * @expectedException \Icewind\SMB\Exception\NotFoundException
396
- */
397
372
public function testRmDirNonExisting () {
373
+ $ this ->expectException (NotFoundException::class);
398
374
$ this ->share ->rmdir ('/foobar/asd ' );
399
375
}
400
376
401
- /**
402
- * @expectedException \Icewind\SMB\Exception\NotFoundException
403
- */
404
377
public function testRenameNonExisting () {
378
+ $ this ->expectException (NotFoundException::class);
405
379
$ this ->share ->rename ('/foobar/asd ' , '/foobar/bar ' );
406
380
}
407
381
408
382
/**
409
383
* @dataProvider invalidPathProvider
410
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
411
384
*/
412
385
public function testRenameInvalidPath ($ name ) {
386
+ $ this ->expectException (InvalidPathException::class);
413
387
$ this ->share ->rename ($ name , $ name . '_ ' );
414
388
}
415
389
416
- /**
417
- * @expectedException \Icewind\SMB\Exception\NotFoundException
418
- */
419
390
public function testRenameTargetNonExisting () {
391
+ $ this ->expectException (NotFoundException::class);
420
392
$ txt = $ this ->getTextFile ();
421
393
$ this ->share ->put ($ txt , $ this ->root . '/foo.txt ' );
422
394
unlink ($ txt );
@@ -448,9 +420,9 @@ public function testReadStream($name, $text) {
448
420
449
421
/**
450
422
* @dataProvider invalidPathProvider
451
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
452
423
*/
453
424
public function testReadStreamInvalidPath ($ name ) {
425
+ $ this ->expectException (InvalidPathException::class);
454
426
$ this ->share ->read ($ name );
455
427
}
456
428
@@ -488,9 +460,9 @@ public function testAppendStream() {
488
460
489
461
/**
490
462
* @dataProvider invalidPathProvider
491
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
492
463
*/
493
464
public function testWriteStreamInvalidPath ($ name ) {
465
+ $ this ->expectException (InvalidPathException::class);
494
466
$ fh = $ this ->share ->write ($ this ->root . '/ ' . $ name );
495
467
fwrite ($ fh , 'foo ' );
496
468
fclose ($ fh );
@@ -525,9 +497,9 @@ public function testDir() {
525
497
526
498
/**
527
499
* @dataProvider invalidPathProvider
528
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
529
500
*/
530
501
public function testDirInvalidPath ($ name ) {
502
+ $ this ->expectException (InvalidPathException::class);
531
503
$ this ->share ->dir ($ name );
532
504
}
533
505
@@ -547,16 +519,14 @@ public function testStat($name) {
547
519
548
520
/**
549
521
* @dataProvider invalidPathProvider
550
- * @expectedException \Icewind\SMB\Exception\InvalidPathException
551
522
*/
552
523
public function testStatInvalidPath ($ name ) {
524
+ $ this ->expectException (InvalidPathException::class);
553
525
$ this ->share ->stat ($ name );
554
526
}
555
527
556
- /**
557
- * @expectedException \Icewind\SMB\Exception\NotFoundException
558
- */
559
528
public function testStatNonExisting () {
529
+ $ this ->expectException (NotFoundException::class);
560
530
$ this ->share ->stat ($ this ->root . '/fo.txt ' );
561
531
}
562
532
@@ -687,10 +657,8 @@ public function testStatRoot() {
687
657
$ this ->assertInstanceOf ('\Icewind\SMB\IFileInfo ' , $ info );
688
658
}
689
659
690
- /**
691
- * @expectedException \Icewind\SMB\Exception\FileInUseException
692
- */
693
660
public function testMoveIntoSelf () {
661
+ $ this ->expectException (FileInUseException::class);
694
662
$ this ->share ->mkdir ($ this ->root . '/folder ' );
695
663
$ this ->share ->rename ($ this ->root . '/folder ' , $ this ->root . '/folder/subfolder ' );
696
664
}
0 commit comments