Skip to content

Commit c0a6302

Browse files
authored
Clean up tests (#59)
* Clean up tests * Remove use of unused class
1 parent cd42ebc commit c0a6302

File tree

6 files changed

+10
-25
lines changed

6 files changed

+10
-25
lines changed

tests/Driver/BlueimpUploadDriverTest.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Illuminate\Http\Request;
1111
use Illuminate\Http\UploadedFile;
1212
use Illuminate\Support\Facades\Event;
13-
use Illuminate\Support\Facades\Session;
1413
use Illuminate\Support\Facades\Storage;
1514
use Mockery;
1615
use PHPUnit\Framework\Constraint\StringContains;
@@ -29,13 +28,11 @@ protected function setUp(): void
2928
{
3029
parent::setUp();
3130

31+
$this->app->make('config')->set('chunk-uploader.identifier', 'nop');
3232
$this->app->make('config')->set('chunk-uploader.uploader', 'blueimp');
3333
$this->app->make('config')->set('chunk-uploader.sweep', false);
3434
$this->handler = $this->app->make(UploadHandler::class);
3535

36-
Session::shouldReceive('getId')
37-
->andReturn('frgYt7cPmNGtORpRCo4xvFIrWklzFqc2mnO6EE6b');
38-
3936
Storage::fake('local');
4037
Event::fake();
4138
}
@@ -82,7 +79,7 @@ public function testDownload()
8279
'download' => 1,
8380
]);
8481

85-
/** @var \Illuminate\Foundation\Testing\TestResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse $response */
82+
/** @var \Illuminate\Testing\TestResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse $response */
8683
$response = $this->createTestResponse($this->handler->handle($request));
8784
$response->assertSuccessful();
8885
$response->assertStatus(200);
@@ -94,10 +91,10 @@ public function testDownload()
9491

9592
public function testResume()
9693
{
97-
$this->createFakeLocalFile('chunks/4f0fce4ab7d03efd246b25d3c9e6546a0d65794d', '000-099');
94+
$this->createFakeLocalFile('chunks/200_test.txt', '000-099');
9895

9996
$request = Request::create('', Request::METHOD_GET, [
100-
'file' => '2494cefe4d234bd331aeb4514fe97d810efba29b.txt',
97+
'file' => 'test.txt',
10198
'totalSize' => '200',
10299
]);
103100

@@ -106,7 +103,7 @@ public function testResume()
106103

107104
$response->assertJson([
108105
'file' => [
109-
'name' => '2494cefe4d234bd331aeb4514fe97d810efba29b.txt',
106+
'name' => 'test.txt',
110107
'size' => 100,
111108
],
112109
]);
@@ -145,12 +142,11 @@ public function testUploadFirstChunk()
145142
'HTTP_CONTENT_RANGE' => 'bytes 0-99/200',
146143
]);
147144

148-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
149145
$response = $this->createTestResponse($this->handler->handle($request));
150146
$response->assertSuccessful();
151147
$response->assertJson(['done' => 50]);
152148

153-
Storage::disk('local')->assertExists('chunks/5d5115c1064c6e9dead0b7b71506bdfe273fd11c/000-099');
149+
Storage::disk('local')->assertExists('chunks/200_test.txt/000-099');
154150

155151
Event::assertNotDispatched(FileUploaded::class, function ($event) use ($file) {
156152
return $event->file = $file->hashName('merged');
@@ -177,7 +173,7 @@ public function testUploadFirstChunkWithCallback()
177173

178174
public function testUploadLastChunk()
179175
{
180-
$this->createFakeLocalFile('chunks/2494cefe4d234bd331aeb4514fe97d810efba29b.txt', '000');
176+
$this->createFakeLocalFile('chunks/200_test.txt', '000');
181177

182178
$file = UploadedFile::fake()->create('test.txt', 100);
183179
$request = Request::create('', Request::METHOD_POST, [], [], [
@@ -186,12 +182,11 @@ public function testUploadLastChunk()
186182
'HTTP_CONTENT_RANGE' => 'bytes 100-199/200',
187183
]);
188184

189-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
190185
$response = $this->createTestResponse($this->handler->handle($request));
191186
$response->assertSuccessful();
192187
$response->assertJson(['done' => 100]);
193188

194-
Storage::disk('local')->assertExists('chunks/5d5115c1064c6e9dead0b7b71506bdfe273fd11c/100-199');
189+
Storage::disk('local')->assertExists('chunks/200_test.txt/100-199');
195190
Storage::disk('local')->assertExists($file->hashName('merged'));
196191

197192
Event::assertDispatched(FileUploaded::class, function ($event) use ($file) {
@@ -201,7 +196,7 @@ public function testUploadLastChunk()
201196

202197
public function testUploadLastChunkWithCallback()
203198
{
204-
$this->createFakeLocalFile('chunks/2494cefe4d234bd331aeb4514fe97d810efba29b.txt', '000');
199+
$this->createFakeLocalFile('chunks/200_test.txt', '000');
205200

206201
$file = UploadedFile::fake()->create('test.txt', 100);
207202
$request = Request::create('', Request::METHOD_POST, [], [], [

tests/Driver/DropzoneUploadDriverTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public function testUploadMonolith()
7272
'file' => $file,
7373
]);
7474

75-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
7675
$response = $this->createTestResponse($this->handler->handle($request));
7776
$response->assertSuccessful();
7877
$response->assertJson(['done' => 100]);
@@ -155,7 +154,6 @@ public function testUploadFirstChunk()
155154
'file' => $file,
156155
]);
157156

158-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
159157
$response = $this->createTestResponse($this->handler->handle($request));
160158
$response->assertSuccessful();
161159
$response->assertJson(['done' => 50]);
@@ -206,7 +204,6 @@ public function testUploadLastChunk()
206204
'file' => $file,
207205
]);
208206

209-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
210207
$response = $this->createTestResponse($this->handler->handle($request));
211208
$response->assertSuccessful();
212209
$response->assertJson(['done' => 100]);

tests/Driver/FlowJsUploadDriverTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ public function testUploadFirstChunk()
190190
'file' => $file,
191191
]);
192192

193-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
194193
$response = $this->createTestResponse($this->handler->handle($request));
195194
$response->assertSuccessful();
196195
$response->assertJson(['done' => 50]);
@@ -245,7 +244,6 @@ public function testUploadLastChunk()
245244
'file' => $file,
246245
]);
247246

248-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
249247
$response = $this->createTestResponse($this->handler->handle($request));
250248
$response->assertSuccessful();
251249
$response->assertJson(['done' => 100]);

tests/Driver/MonolithUploadDriverTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testDownload()
5050
'file' => 'local-test-file',
5151
]);
5252

53-
/** @var \Illuminate\Foundation\Testing\TestResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse $response */
53+
/** @var \Illuminate\Testing\TestResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse $response */
5454
$response = $this->createTestResponse($this->handler->handle($request));
5555
$response->assertSuccessful();
5656
$response->assertStatus(200);
@@ -102,7 +102,6 @@ public function testUpload()
102102
'file' => $file,
103103
]);
104104

105-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
106105
$response = $this->createTestResponse($this->handler->handle($request));
107106
$response->assertSuccessful();
108107

tests/Driver/ResumableJsUploadDriverTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ public function testUploadFirstChunk()
195195
'file' => $file,
196196
]);
197197

198-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
199198
$response = $this->createTestResponse($this->handler->handle($request));
200199
$response->assertSuccessful();
201200
$response->assertJson(['done' => 50]);
@@ -252,7 +251,6 @@ public function testUploadLastChunk()
252251
'file' => $file,
253252
]);
254253

255-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
256254
$response = $this->createTestResponse($this->handler->handle($request));
257255
$response->assertSuccessful();
258256
$response->assertJson(['done' => 100]);

tests/Driver/SimpleUploaderUploadDriverTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ public function testUploadFirstChunk()
190190
'file' => $file,
191191
]);
192192

193-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
194193
$response = $this->createTestResponse($this->handler->handle($request));
195194
$response->assertSuccessful();
196195
$response->assertJson(['done' => 50]);
@@ -245,7 +244,6 @@ public function testUploadLastChunk()
245244
'file' => $file,
246245
]);
247246

248-
/** @var \Illuminate\Foundation\Testing\TestResponse $response */
249247
$response = $this->createTestResponse($this->handler->handle($request));
250248
$response->assertSuccessful();
251249
$response->assertJson(['done' => 100]);

0 commit comments

Comments
 (0)