From dc2881e640c0c7891458f0f7e7d8f20f5b86c3eb Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 3 Dec 2023 14:43:45 +0100 Subject: [PATCH 1/7] Update composer.json --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index b67d234..a27f293 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,10 @@ "psr-4": { "Dilab\\Test\\": "test/src/" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } From edfca757efe5b4015b9ceaa7a075a34a6b61085c Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 5 Apr 2021 15:28:34 +0200 Subject: [PATCH 2/7] Add a .gitattributes file --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..534a144 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/.github export-ignore +/phpcs.xml export-ignore +/.editorconfig export-ignore From cea27bf67413e18b92f6bbfec42aa19043b6b966 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:21:49 +0100 Subject: [PATCH 3/7] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7a1e76a..a62d70a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ vendor/* composer.lock .idea +.vscode .phpunit.cache/* -.phpunit.*.cache \ No newline at end of file +.phpunit.*.cache From e856b0e3aed3892ae2585116dc62fcf07615a0d4 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 5 Apr 2021 12:58:04 +0200 Subject: [PATCH 4/7] Add a LICENSE text --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..483d564 --- /dev/null +++ b/LICENSE @@ -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. From 0d0f22e4e212e7b2787e8ea6866957b921222ab6 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:26:22 +0100 Subject: [PATCH 5/7] Add tests workflow --- .github/workflows/tests.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..0195a70 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 \ No newline at end of file From 95c965ae8a7977e951a2540c32eb3074d8b5fa00 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:30:23 +0100 Subject: [PATCH 6/7] Fix tests after #36 --- test/src/ResumableTest.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/src/ResumableTest.php b/test/src/ResumableTest.php index 4afe706..68673ee 100644 --- a/test/src/ResumableTest.php +++ b/test/src/ResumableTest.php @@ -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'; @@ -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() From 875a341b504dd450e8515a0135fe42b3e8b7fe39 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:37:58 +0100 Subject: [PATCH 7/7] Remove not used lines --- .gitattributes | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 534a144..17d5dc6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,3 @@ /.gitattributes export-ignore /.gitignore export-ignore /.github export-ignore -/phpcs.xml export-ignore -/.editorconfig export-ignore