-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
1 changed file
with
120 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,120 @@ | ||
<?php | ||
|
||
namespace Aedart\Tests\Unit\Utils\Random; | ||
|
||
use Aedart\Testing\Helpers\ConsoleDebugger; | ||
use Aedart\Testing\TestCases\UnitTestCase; | ||
use Aedart\Utils\Random\Factory; | ||
use Throwable; | ||
|
||
/** | ||
* RandomizerTest | ||
* | ||
* @group utils | ||
* @group utils-random | ||
* @group utils-randomizer | ||
* | ||
* @author Alin Eugen Deac <[email protected]> | ||
* @package Aedart\Tests\Unit\Utils\Random | ||
*/ | ||
class RandomizerTest extends UnitTestCase | ||
{ | ||
// NOTE: These tests do NOT verify randomness. Only that API methods can be invoked | ||
// and return value(s)... | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canGetRandomBytes(): void | ||
{ | ||
$result = Factory::make()->bytes(10); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsString($result); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canShuffleBytes(): void | ||
{ | ||
$result = Factory::make()->shuffleBytes(implode('', range('a', 'z'))); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsString($result); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canGetRandomInt(): void | ||
{ | ||
$result = Factory::make()->int(1, 10); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsInt($result); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canGetNextInt(): void | ||
{ | ||
$result = Factory::make()->nextInt(); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsInt($result); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canPickArrayKeys(): void | ||
{ | ||
$result = Factory::make()->pickKeys([ 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5 ], 2); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsArray($result); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @return void | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function canShuffleArray(): void | ||
{ | ||
$result = Factory::make()->shuffle([ 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5 ]); | ||
|
||
ConsoleDebugger::output($result); | ||
|
||
$this->assertIsArray($result); | ||
} | ||
} |