From 3c7bd63ea3b68464a562818d0dc15a7f741f614c Mon Sep 17 00:00:00 2001 From: Koen Hoeijmakers Date: Sat, 31 Mar 2018 09:51:32 +0200 Subject: [PATCH 1/2] ignore composer.lock --- .gitignore | 1 + composer.json | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f417e74..2130d09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea /vendor +composer.lock diff --git a/composer.json b/composer.json index a65b0a4..1b4f326 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,8 @@ "description": "Argon2 implementation", "require": { "php": "^7.2", - "illuminate/hashing": "5.0 - 5.5" + "illuminate/hashing": "5.0 - 5.5", + "phpunit/phpunit": "^7.0" }, "license": "MIT", "authors": [ @@ -16,5 +17,10 @@ "psr-4": { "KoenHoeijmakers\\LaravelArgon2\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "KoenHoeijmakers\\LaravelArgon2\\Tests\\": "tests/" + } } } From c107973066a2e540a6063bf447c5cfe424c07ff7 Mon Sep 17 00:00:00 2001 From: Koen Hoeijmakers Date: Sat, 31 Mar 2018 09:57:50 +0200 Subject: [PATCH 2/2] add unit testing --- phpunit.xml | 17 +++++++++++++++++ tests/Unit/Argon2HasherTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 phpunit.xml create mode 100644 tests/Unit/Argon2HasherTest.php diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..700ca84 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,17 @@ + + + + + ./tests/ + + + diff --git a/tests/Unit/Argon2HasherTest.php b/tests/Unit/Argon2HasherTest.php new file mode 100644 index 0000000..92b7e9b --- /dev/null +++ b/tests/Unit/Argon2HasherTest.php @@ -0,0 +1,24 @@ +markTestSkipped('PHP not compiled with argon2 hashing support.'); + } + + $hasher = new Argon2Hasher(); + + $value = $hasher->make('password'); + $this->assertNotSame('password', $value); + $this->assertTrue($hasher->check('password', $value)); + $this->assertFalse($hasher->needsRehash($value)); + $this->assertTrue($hasher->needsRehash($value, ['threads' => 1])); + } +}