Skip to content

Commit

Permalink
Merge pull request #37 from code-lts/backports
Browse files Browse the repository at this point in the history
Backports from my forked version
  • Loading branch information
dilab authored Dec 17, 2023
2 parents 27fa0c5 + 875a341 commit d7a4f11
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 deletions.
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

0 comments on commit d7a4f11

Please sign in to comment.