Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rename RandomGenerator to BytesGenerator
- Loading branch information
Showing
13 changed files
with
105 additions
and
96 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
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
tests/unit/Service/BytesGenerator/FixedBytesGeneratorTest.php
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ramsey\Test\Identifier\Service\BytesGenerator; | ||
|
||
use Ramsey\Identifier\Service\BytesGenerator\FixedBytesGenerator; | ||
use Ramsey\Test\Identifier\TestCase; | ||
|
||
class FixedBytesGeneratorTest extends TestCase | ||
{ | ||
public function testGetBytesWithLengthExactlyAsValueProvided(): void | ||
{ | ||
$bytes = "\xab\xcd\xef\x01\x23\x45\x67\x89"; | ||
$randomGenerator = new FixedBytesGenerator($bytes); | ||
|
||
$this->assertSame($bytes, $randomGenerator->bytes(8)); | ||
} | ||
|
||
public function testGetBytesWithLengthGreaterThanValueProvided(): void | ||
{ | ||
$bytes = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; | ||
$randomGenerator = new FixedBytesGenerator($bytes); | ||
|
||
$this->assertSame($bytes, $randomGenerator->bytes(20)); | ||
} | ||
|
||
public function testGetBytesWithLengthLessThanValueProvided(): void | ||
{ | ||
$bytes = "\xff\xff\xff\xff\xab\xcd\xef\x01\x23\x45\x67\x89\xff\xff\xff\xff"; | ||
$randomGenerator = new FixedBytesGenerator($bytes); | ||
|
||
$this->assertSame("\xff\xff\xff\xff\xab\xcd\xef\x01", $randomGenerator->bytes(8)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/unit/Service/BytesGenerator/RandomBytesGeneratorTest.php
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ramsey\Test\Identifier\Service\BytesGenerator; | ||
|
||
use Ramsey\Identifier\Service\BytesGenerator\RandomBytesGenerator; | ||
use Ramsey\Test\Identifier\TestCase; | ||
|
||
use function strlen; | ||
|
||
class RandomBytesGeneratorTest extends TestCase | ||
{ | ||
public function testGetRandomBytes(): void | ||
{ | ||
$randomGenerator = new RandomBytesGenerator(); | ||
|
||
$this->assertSame(16, strlen($randomGenerator->bytes(16))); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
tests/unit/Service/RandomGenerator/FrozenRandomGeneratorTest.php
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
tests/unit/Service/RandomGenerator/PhpRandomGeneratorTest.php
This file was deleted.
Oops, something went wrong.
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
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