Skip to content

Commit d7a4f11

Browse files
authored
Merge pull request dilab#37 from code-lts/backports
Backports from my forked version
2 parents 27fa0c5 + 875a341 commit d7a4f11

File tree

6 files changed

+73
-9
lines changed

6 files changed

+73
-9
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.github export-ignore

.github/workflows/tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run phpunit tests
2+
3+
permissions:
4+
contents: read
5+
6+
on: [push]
7+
8+
jobs:
9+
test-php:
10+
name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php-version: ["8.1", "8.2", "8.3"]
16+
os: [ubuntu-latest]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Use php ${{ matrix.php-version }}
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php-version }}
23+
- name: Cache module
24+
uses: actions/cache@v3
25+
with:
26+
path: ~/.composer/cache/
27+
key: composer-cache
28+
- name: Install dependencies
29+
run: composer install --no-interaction
30+
- name: Run php tests
31+
run: ./vendor/bin/phpunit

.gitignore

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

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2015-2018 xu ding
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@
2525
"psr-4": {
2626
"Dilab\\Test\\": "test/src/"
2727
}
28+
},
29+
"config": {
30+
"allow-plugins": {
31+
"dealerdirect/phpcodesniffer-composer-installer": true
32+
}
2833
}
2934
}

test/src/ResumableTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testHandleTestChunk()
115115

116116
$this->response->expects($this->once())
117117
->method('header')
118-
->with($this->equalTo(200));
118+
->with($this->equalTo(201));
119119

120120
$this->resumbable = new Resumable($this->request,$this->response);
121121
$this->resumbable->tempFolder = 'test/tmp';
@@ -184,22 +184,25 @@ public function testResumableParamsGetRequest()
184184

185185
public static function isFileUploadCompleteProvider()
186186
{
187-
return array(
188-
array('mock.png', 'files', 20, 60, true),
189-
array('mock.png','files', 25, 60, true),
190-
array('mock.png','files', 10, 60, false),
191-
);
187+
return [
188+
['mock.png', 'files', 1, true],// test/files/0001-0003 exist
189+
['mock.png', 'files', 2, true],// test/files/0001-0003 exist
190+
['mock.png', 'files', 3, true],// test/files/0001-0003 exist
191+
['mock.png', 'files', 4, false],// no 0004 chunk
192+
['mock.png', 'files', 5, false],// no 0004-0005 chunks
193+
['mock.png', 'files', 15, false],// no 0004-00015 chunks
194+
];
192195
}
193196

194197
/**
195198
*
196199
* @dataProvider isFileUploadCompleteProvider
197200
*/
198-
public function testIsFileUploadComplete($filename,$identifier, $chunkSize, $totalSize, $expected)
201+
public function testIsFileUploadComplete($filename,$identifier, $totalChunks, $expected)
199202
{
200203
$this->resumbable = new Resumable($this->request,$this->response);
201204
$this->resumbable->tempFolder ='test';
202-
$this->assertEquals($expected, $this->resumbable->isFileUploadComplete($filename, $identifier, $chunkSize, $totalSize));
205+
$this->assertEquals($expected, $this->resumbable->isFileUploadComplete($filename, $identifier, $totalChunks));
203206
}
204207

205208
public function testIsChunkUploaded()

0 commit comments

Comments
 (0)