Skip to content

Commit 6c0a31a

Browse files
committed
Merge 'dilab/master'
2 parents ede435d + 27fa0c5 commit 6c0a31a

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ vendor/*
22
composer.lock
33
.idea
44
.vscode
5-
/.phpunit.result.cache
5+
.phpunit.cache/*
6+
.phpunit.*.cache
67
/build

phpunit.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" backupGlobals="false" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.result.cache">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="./vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.result.cache" backupStaticProperties="false">
33
<coverage>
44
<report>
55
<clover outputFile="build/logs/clover.xml"/>
@@ -8,8 +8,8 @@
88
</coverage>
99
<logging/>
1010
<testsuites>
11-
<testsuite name="Unit tests">
12-
<directory suffix=".php">test/</directory>
11+
<testsuite name="Package Test Suite">
12+
<directory suffix=".php">./test/</directory>
1313
</testsuite>
1414
</testsuites>
1515
<source>
File renamed without changes.

src/Resumable.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@ public function handleChunk(): ResponseInterface
198198
$files = $this->request->getUploadedFiles();
199199
$identifier = $this->resumableParam($this->resumableOption['identifier']);
200200
$filename = $this->resumableParam($this->resumableOption['filename']);
201-
$totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']);
202201
$chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']);
203202
$chunkSize = (int) $this->resumableParam($this->resumableOption['chunkSize']);
204-
$totalSize = (int) $this->resumableParam($this->resumableOption['totalSize']);
203+
$totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']);
205204

206205
if ($chunkSize <= 0) {
207206
$this->log('The chunk size is <= 0');
@@ -212,7 +211,7 @@ public function handleChunk(): ResponseInterface
212211
if (count($files) > 0) {
213212
$firstFile = array_shift($files);
214213
if ($firstFile instanceof UploadedFileInterface) {
215-
$chunkDir = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR;
214+
$chunkDir = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR;
216215
$this->chunkFile = $chunkDir . $this->tmpChunkFilename($filename, $chunkNumber);
217216
$this->log('Moving chunk', ['identifier' => $identifier, 'chunkNumber' => $chunkNumber]);
218217
// On the server that received the upload
@@ -316,10 +315,10 @@ public function resumableParams(): array
316315
return [];
317316
}
318317

319-
public function isFileUploadComplete(string $filename, string $identifier, int $numOfChunks): bool
318+
public function isFileUploadComplete(string $filename, string $identifier, int $totalChunks): bool
320319
{
321-
for ($i = 1; $i <= $numOfChunks; $i++) {
322-
if (! $this->isChunkUploaded($identifier, $filename, $i)) {
320+
for ($i = 1; $i <= $totalChunks; $i++) {
321+
if (!$this->isChunkUploaded($identifier, $filename, $i)) {
323322
return false;
324323
}
325324
}

test/src/ResumableTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ protected function setUp(): void
3535
{
3636
$this->psr17Factory = new Psr17Factory();
3737

38-
$this->request = $this->psr17Factory->createServerRequest('GET', 'http://example.com');
38+
$this->request = $this->psr17Factory->createServerRequest('GET', 'http://example.com');
3939
$this->response = $this->psr17Factory->createResponse(200);
4040
$this->refreshResumable();
4141
}
4242

4343
private function refreshResumable(): void
4444
{
45-
$this->resumable = new Resumable($this->request, $this->response);
45+
$this->resumable = new Resumable($this->request, $this->response);
4646
$this->resumable->tempFolder = 'test/tmp';
4747
$this->resumable->uploadFolder = 'test/uploads';
4848
}
@@ -200,7 +200,6 @@ public function testHandleChunk(): void
200200
$this->assertFileDoesNotExist($uploadedFile);// It was moved
201201

202202
$this->assertTrue(unlink($this->resumable->uploadFolder . '/' . $uploadedFileName));
203-
204203
}
205204

206205
public function testResumableParamsGetRequest(): void
@@ -322,9 +321,9 @@ public function testTmpChunkDir(): void
322321

323322
public function testTmpChunkFile(): void
324323
{
325-
$filename = 'example-file.png';
326-
$chunkNumber = 1;
327-
$expected = $filename . '.' . str_pad((string) $chunkNumber, 4, '0', STR_PAD_LEFT);
324+
$filename = 'example-file.png';
325+
$chunkNumber = 1;
326+
$expected = $filename . '.' . str_pad((string) $chunkNumber, 4, '0', STR_PAD_LEFT);
328327
$this->assertEquals($expected, $this->resumable->tmpChunkFilename($filename, $chunkNumber));
329328
}
330329

0 commit comments

Comments
 (0)