Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions tests/Driver/BlueimpUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use Mockery;
use PHPUnit\Framework\Constraint\StringContains;
Expand All @@ -29,13 +28,11 @@ protected function setUp(): void
{
parent::setUp();

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

Session::shouldReceive('getId')
->andReturn('frgYt7cPmNGtORpRCo4xvFIrWklzFqc2mnO6EE6b');

Storage::fake('local');
Event::fake();
}
Expand Down Expand Up @@ -82,7 +79,7 @@ public function testDownload()
'download' => 1,
]);

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

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

$request = Request::create('', Request::METHOD_GET, [
'file' => '2494cefe4d234bd331aeb4514fe97d810efba29b.txt',
'file' => 'test.txt',
'totalSize' => '200',
]);

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

$response->assertJson([
'file' => [
'name' => '2494cefe4d234bd331aeb4514fe97d810efba29b.txt',
'name' => 'test.txt',
'size' => 100,
],
]);
Expand Down Expand Up @@ -145,12 +142,11 @@ public function testUploadFirstChunk()
'HTTP_CONTENT_RANGE' => 'bytes 0-99/200',
]);

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

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

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

public function testUploadLastChunk()
{
$this->createFakeLocalFile('chunks/2494cefe4d234bd331aeb4514fe97d810efba29b.txt', '000');
$this->createFakeLocalFile('chunks/200_test.txt', '000');

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

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

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

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

public function testUploadLastChunkWithCallback()
{
$this->createFakeLocalFile('chunks/2494cefe4d234bd331aeb4514fe97d810efba29b.txt', '000');
$this->createFakeLocalFile('chunks/200_test.txt', '000');

$file = UploadedFile::fake()->create('test.txt', 100);
$request = Request::create('', Request::METHOD_POST, [], [], [
Expand Down
3 changes: 0 additions & 3 deletions tests/Driver/DropzoneUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function testUploadMonolith()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 100]);
Expand Down Expand Up @@ -155,7 +154,6 @@ public function testUploadFirstChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 50]);
Expand Down Expand Up @@ -206,7 +204,6 @@ public function testUploadLastChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 100]);
Expand Down
2 changes: 0 additions & 2 deletions tests/Driver/FlowJsUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public function testUploadFirstChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 50]);
Expand Down Expand Up @@ -245,7 +244,6 @@ public function testUploadLastChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 100]);
Expand Down
3 changes: 1 addition & 2 deletions tests/Driver/MonolithUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testDownload()
'file' => 'local-test-file',
]);

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

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

Expand Down
2 changes: 0 additions & 2 deletions tests/Driver/ResumableJsUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ public function testUploadFirstChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 50]);
Expand Down Expand Up @@ -252,7 +251,6 @@ public function testUploadLastChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 100]);
Expand Down
2 changes: 0 additions & 2 deletions tests/Driver/SimpleUploaderUploadDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public function testUploadFirstChunk()
'file' => $file,
]);

/** @var \Illuminate\Foundation\Testing\TestResponse $response */
$response = $this->createTestResponse($this->handler->handle($request));
$response->assertSuccessful();
$response->assertJson(['done' => 50]);
Expand Down Expand Up @@ -245,7 +244,6 @@ public function testUploadLastChunk()
'file' => $file,
]);

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