From 1d6c08ecb02fd05f3311e5be7646360db2f3db19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20G=C3=B6r=C3=B6g?= Date: Sun, 14 Jun 2020 16:59:17 +0200 Subject: [PATCH 1/2] Add NOP identifier --- README.md | 9 ++++++- src/Identifier/NopIdentifier.php | 11 +++++++++ src/IdentityManager.php | 6 +++++ tests/Identifier/NopIdentifierTest.php | 34 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/Identifier/NopIdentifier.php create mode 100644 tests/Identifier/NopIdentifierTest.php diff --git a/README.md b/README.md index 4aa5d52..bb2d525 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ project at the moment is [tus](https://tus.io/). - [simple-uploader.js](#simple-uploader-js-driver) - [Identifiers](#identifiers) - [Session identifier](#session-identifier) + - [NOP identifier](#nop-identifier) - [Contribution](#contribution) - [License](#license) @@ -197,10 +198,16 @@ file for a specific client. Without the identifier collisions can happen. Service | Driver name ------------------------------------------|------------- [Session identifier](#session-identifier) | `session` +[NOP identifier](#nop-identifier) | `nop` ### Session identifier -This identifier uses the client session and the original file name to create an identifier for the upload file. +This identifier uses the client session and, the original file name to create an identifier for the upload file. + +### NOP identifier + +This identifier uses the original file name to create an identifier for the upload file. This does not abstract the file +identifier which can be useful for testing. ## Contribution diff --git a/src/Identifier/NopIdentifier.php b/src/Identifier/NopIdentifier.php new file mode 100644 index 0000000..1e66c96 --- /dev/null +++ b/src/Identifier/NopIdentifier.php @@ -0,0 +1,11 @@ +identifier = new NopIdentifier(); + } + + public function testGenerateIdentifier() + { + $identifier = $this->identifier->generateIdentifier('any_string'); + $this->assertEquals('any_string', $identifier); + } + + public function testUploadedFileIdentifierName() + { + $identifier = $this->identifier->generateFileIdentifier(200, 'any_filename.ext'); + $this->assertEquals('200_any_filename.ext', $identifier); + } +} From 0fbfd405ead179295e8073902bcf7ef9074ff9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20G=C3=B6r=C3=B6g?= Date: Sat, 20 Jun 2020 18:25:57 +0200 Subject: [PATCH 2/2] Remove use of unused class --- tests/Identifier/NopIdentifierTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Identifier/NopIdentifierTest.php b/tests/Identifier/NopIdentifierTest.php index 4b529f4..10947f0 100644 --- a/tests/Identifier/NopIdentifierTest.php +++ b/tests/Identifier/NopIdentifierTest.php @@ -2,7 +2,6 @@ namespace CodingSocks\ChunkUploader\Tests\Identifier; -use Illuminate\Http\UploadedFile; use CodingSocks\ChunkUploader\Identifier\NopIdentifier; use PHPUnit\Framework\TestCase;