-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7b1cdf
commit 8806d44
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Keygen\Generators\AlphaNumericGenerator; | ||
|
||
/** | ||
* @coversDefaultClass AlphaNumericGenerator | ||
*/ | ||
final class AlphaNumericGeneratorTest extends TestCase | ||
{ | ||
protected $generator; | ||
|
||
protected function setUp() | ||
{ | ||
$this->generator = new AlphaNumericGenerator; | ||
} | ||
|
||
/** | ||
* @covers ::keygen | ||
* @covers Keygen\Generator::generate | ||
*/ | ||
public function testKeyGeneration() | ||
{ | ||
$key = $this->generator->generate(); | ||
$this->assertRegExp('/^[a-zA-Z0-9]{16}$/', $key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Keygen\Generators\NumericGenerator; | ||
|
||
/** | ||
* @coversDefaultClass NumericGenerator | ||
*/ | ||
final class NumericGeneratorTest extends TestCase | ||
{ | ||
protected $generator; | ||
|
||
protected function setUp() | ||
{ | ||
$this->generator = new NumericGenerator; | ||
} | ||
|
||
/** | ||
* @covers ::keygen | ||
* @covers Keygen\Generator::generate | ||
*/ | ||
public function testKeyGeneration() | ||
{ | ||
$key = $this->generator->generate(); | ||
$this->assertRegExp('/^\d{16}$/', $key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Keygen\Generators\RandomByteGenerator; | ||
|
||
/** | ||
* @coversDefaultClass RandomByteGenerator | ||
*/ | ||
final class RandomByteGeneratorTest extends TestCase | ||
{ | ||
protected $generator; | ||
|
||
protected function setUp() | ||
{ | ||
$this->generator = new RandomByteGenerator; | ||
} | ||
|
||
/** | ||
* @covers ::hex | ||
* @covers ::keygen | ||
* @covers ::generate | ||
* @covers Keygen\Generator::generate | ||
*/ | ||
public function testKeyGeneration() | ||
{ | ||
$key = $this->generator->generate(); | ||
$this->assertEquals(16, strlen($key)); | ||
|
||
$this->assertFalse($this->generator->hex); | ||
$hexKey = $this->generator->hex()->generate(); | ||
$this->assertRegExp('/^[a-f0-9]{16}$/', $hexKey); | ||
$this->assertFalse($this->generator->hex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Keygen\Generators\TokenGenerator; | ||
|
||
/** | ||
* @coversDefaultClass TokenGenerator | ||
*/ | ||
final class TokenGeneratorTest extends TestCase | ||
{ | ||
protected $generator; | ||
|
||
protected function setUp() | ||
{ | ||
$this->generator = new TokenGenerator; | ||
} | ||
|
||
/** | ||
* @covers ::keygen | ||
* @covers Keygen\Generator::generate | ||
*/ | ||
public function testKeyGeneration() | ||
{ | ||
$key = $this->generator->generate(); | ||
$this->assertRegExp('/^[a-zA-Z0-9+\/]{16}$/', $key); | ||
} | ||
} |