9
9
10
10
class UserDiskControllerTest extends ApiTestCase
11
11
{
12
- private $ mockS3 = null ;
12
+ private $ mockS3 ;
13
+
13
14
public function setUp (): void
14
15
{
15
16
parent ::setUp ();
@@ -47,7 +48,6 @@ public function testStore()
47
48
public function testStoreS3 ()
48
49
{
49
50
$ this ->beUser ();
50
-
51
51
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
52
52
$ this ->postJson ("/api/v1/user-disks " , [
53
53
'name ' => 'my disk ' ,
@@ -86,7 +86,6 @@ public function testStoreS3()
86
86
87
87
public function testDuplicateNames (){
88
88
$ this ->beUser ();
89
-
90
89
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->once ()->andReturn ([]);
91
90
$ this ->postJson ("/api/v1/user-disks " , [
92
91
'name ' => 'my disk ' ,
@@ -128,7 +127,6 @@ public function testDuplicateNames(){
128
127
public function testStoreS3RegionEmpty ()
129
128
{
130
129
$ this ->beUser ();
131
-
132
130
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->once ()->andReturn ([]);
133
131
$ this ->postJson ("/api/v1/user-disks " , [
134
132
'name ' => 'my disk ' ,
@@ -148,7 +146,6 @@ public function testStoreS3RegionEmpty()
148
146
public function testStoreS3PathStyle ()
149
147
{
150
148
$ this ->beUser ();
151
-
152
149
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
153
150
$ this ->postJson ("/api/v1/user-disks " , [
154
151
'name ' => 'my disk ' ,
@@ -374,7 +371,6 @@ public function testDestroy()
374
371
public function testStoreInvalidS3Config ()
375
372
{
376
373
$ this ->beUser ();
377
-
378
374
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
379
375
$ this ->postJson ("/api/v1/user-disks " , [
380
376
'name ' => 'my disk ' ,
@@ -384,8 +380,7 @@ public function testStoreInvalidS3Config()
384
380
'bucket ' => 'ucket ' ,
385
381
'region ' => '' ,
386
382
'endpoint ' => 'http://bucket.example.com ' ,
387
- ])
388
- ->assertUnprocessable ();
383
+ ])->assertUnprocessable ();
389
384
390
385
$ disk = UserDisk::where ('user_id ' , $ this ->user ()->id )->first ();
391
386
$ this ->assertEmpty ($ disk );
@@ -410,8 +405,7 @@ public function testUpdateInvalidS3Config()
410
405
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
411
406
$ this ->putJson ("/api/v1/user-disks/ {$ disk ->id }" , [
412
407
'endpoint ' => 'https://bucket.example.com ' ,
413
- ])
414
- ->assertUnprocessable ();
408
+ ])->assertUnprocessable ();
415
409
416
410
$ disk = $ disk ->fresh ();
417
411
$ this ->assertEquals ('https://jkl.example.com ' , $ disk ->options ['endpoint ' ]);
@@ -420,7 +414,6 @@ public function testUpdateInvalidS3Config()
420
414
public function testStoreIncorrectBucketName ()
421
415
{
422
416
$ this ->beUser ();
423
-
424
417
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
425
418
$ this ->postJson ("/api/v1/user-disks " , [
426
419
'name ' => 'my disk ' ,
@@ -430,8 +423,7 @@ public function testStoreIncorrectBucketName()
430
423
'bucket ' => 'ucket ' ,
431
424
'region ' => '' ,
432
425
'endpoint ' => 'http://bucket.example.com ' ,
433
- ])
434
- ->assertUnprocessable ();
426
+ ])->assertUnprocessable ();
435
427
436
428
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
437
429
$ this ->postJson ("/api/v1/user-disks " , [
@@ -442,8 +434,7 @@ public function testStoreIncorrectBucketName()
442
434
'bucket ' => 'bucket ' ,
443
435
'region ' => '' ,
444
436
'endpoint ' => 'http://ucket.example.com ' ,
445
- ])
446
- ->assertUnprocessable ();
437
+ ])->assertUnprocessable ();
447
438
448
439
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
449
440
$ this ->postJson ("/api/v1/user-disks " , [
@@ -454,8 +445,7 @@ public function testStoreIncorrectBucketName()
454
445
'bucket ' => 'ucket ' ,
455
446
'region ' => '' ,
456
447
'endpoint ' => 'http://example.com/bucket ' ,
457
- ])
458
- ->assertUnprocessable ();
448
+ ])->assertUnprocessable ();
459
449
460
450
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
461
451
$ this ->postJson ("/api/v1/user-disks " , [
@@ -466,8 +456,7 @@ public function testStoreIncorrectBucketName()
466
456
'bucket ' => 'bucket ' ,
467
457
'region ' => '' ,
468
458
'endpoint ' => 'http://example.com/ucket ' ,
469
- ])
470
- ->assertUnprocessable ();
459
+ ])->assertUnprocessable ();
471
460
}
472
461
473
462
public function testUpdateIncorrectBucketName ()
@@ -496,8 +485,7 @@ public function testUpdateIncorrectBucketName()
496
485
'bucket ' => 'm ' ,
497
486
'region ' => 'us-east-2 ' ,
498
487
'endpoint ' => 'https://onm.example.com ' ,
499
- ])
500
- ->assertUnprocessable ();
488
+ ])->assertUnprocessable ();
501
489
502
490
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
503
491
$ this ->putJson ("/api/v1/user-disks/ {$ disk ->id }" , [
@@ -508,8 +496,7 @@ public function testUpdateIncorrectBucketName()
508
496
'bucket ' => 'onm ' ,
509
497
'region ' => 'us-east-2 ' ,
510
498
'endpoint ' => 'https://m.example.com ' ,
511
- ])
512
- ->assertUnprocessable ();
499
+ ])->assertUnprocessable ();
513
500
514
501
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
515
502
$ this ->putJson ("/api/v1/user-disks/ {$ disk ->id }" , [
@@ -520,8 +507,7 @@ public function testUpdateIncorrectBucketName()
520
507
'bucket ' => 'm ' ,
521
508
'region ' => 'us-east-2 ' ,
522
509
'endpoint ' => 'https://example.com/onm ' ,
523
- ])
524
- ->assertUnprocessable ();
510
+ ])->assertUnprocessable ();
525
511
526
512
$ this ->mockS3 ->shouldReceive ('canAccessDisk ' )->never ();
527
513
$ this ->putJson ("/api/v1/user-disks/ {$ disk ->id }" , [
@@ -532,7 +518,6 @@ public function testUpdateIncorrectBucketName()
532
518
'bucket ' => 'onm ' ,
533
519
'region ' => 'us-east-2 ' ,
534
520
'endpoint ' => 'https://example.com/m ' ,
535
- ])
536
- ->assertUnprocessable ();
521
+ ])->assertUnprocessable ();
537
522
}
538
523
}
0 commit comments