Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports from my forked version #37

Merged
merged 7 commits into from
Dec 17, 2023
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run phpunit tests

permissions:
contents: read

on: [push]

jobs:
test-php:
name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php-version: ["8.1", "8.2", "8.3"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Use php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Cache module
uses: actions/cache@v3
with:
path: ~/.composer/cache/
key: composer-cache
- name: Install dependencies
run: composer install --no-interaction
- name: Run php tests
run: ./vendor/bin/phpunit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor/*
composer.lock
.idea
.vscode
.phpunit.cache/*
.phpunit.*.cache
.phpunit.*.cache
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2015-2018 xu ding

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"psr-4": {
"Dilab\\Test\\": "test/src/"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
19 changes: 11 additions & 8 deletions test/src/ResumableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function testHandleTestChunk()

$this->response->expects($this->once())
->method('header')
->with($this->equalTo(200));
->with($this->equalTo(201));

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

public static function isFileUploadCompleteProvider()
{
return array(
array('mock.png', 'files', 20, 60, true),
array('mock.png','files', 25, 60, true),
array('mock.png','files', 10, 60, false),
);
return [
['mock.png', 'files', 1, true],// test/files/0001-0003 exist
['mock.png', 'files', 2, true],// test/files/0001-0003 exist
['mock.png', 'files', 3, true],// test/files/0001-0003 exist
['mock.png', 'files', 4, false],// no 0004 chunk
['mock.png', 'files', 5, false],// no 0004-0005 chunks
['mock.png', 'files', 15, false],// no 0004-00015 chunks
];
}

/**
*
* @dataProvider isFileUploadCompleteProvider
*/
public function testIsFileUploadComplete($filename,$identifier, $chunkSize, $totalSize, $expected)
public function testIsFileUploadComplete($filename,$identifier, $totalChunks, $expected)
{
$this->resumbable = new Resumable($this->request,$this->response);
$this->resumbable->tempFolder ='test';
$this->assertEquals($expected, $this->resumbable->isFileUploadComplete($filename, $identifier, $chunkSize, $totalSize));
$this->assertEquals($expected, $this->resumbable->isFileUploadComplete($filename, $identifier, $totalChunks));
}

public function testIsChunkUploaded()
Expand Down