Skip to content

Commit

Permalink
Merge pull request #5 from koenhoeijmakers/unit
Browse files Browse the repository at this point in the history
Added Unit Tests
  • Loading branch information
koenhoeijmakers authored Mar 31, 2018
2 parents 0452faf + c107973 commit 9f0f90b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea
/vendor
composer.lock
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -16,5 +17,10 @@
"psr-4": {
"KoenHoeijmakers\\LaravelArgon2\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"KoenHoeijmakers\\LaravelArgon2\\Tests\\": "tests/"
}
}
}
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Laravel Argon2 test suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
24 changes: 24 additions & 0 deletions tests/Unit/Argon2HasherTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace KoenHoeijmakers\LaravelArgon2\Tests\Unit;

use KoenHoeijmakers\LaravelArgon2\Argon2Hasher;
use PHPUnit\Framework\TestCase;

class Argon2HasherTest extends TestCase
{
public function testArgon2Hashing()
{
if (! defined('PASSWORD_ARGON2I')) {
$this->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]));
}
}

0 comments on commit 9f0f90b

Please sign in to comment.