mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 12:48:08 +09:00
* Added the rector cache to the action * Enabled PHP-CS fixer for the tests & library folder * Use the PHP-CS-Fixer Cache * Fix the tests * Ensure the Sentry placeholder isn't messed up from CS changes * Typo..
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
class Box_PasswordTest extends PHPUnit\Framework\TestCase
|
|
{
|
|
public function testsetAlgo()
|
|
{
|
|
$boxPassword = new Box_Password();
|
|
$algo = PASSWORD_BCRYPT;
|
|
$boxPassword->setAlgo($algo);
|
|
$result = $boxPassword->getAlgo();
|
|
$this->assertEquals($algo, $result);
|
|
}
|
|
|
|
public function testSetOptions()
|
|
{
|
|
$boxPassword = new Box_Password();
|
|
$options = [
|
|
'cost' => 12,
|
|
];
|
|
$boxPassword->setOptions($options);
|
|
$result = $boxPassword->getOptions();
|
|
$this->assertEquals($options, $result);
|
|
}
|
|
|
|
public function testHashing()
|
|
{
|
|
$boxPassword = new Box_Password();
|
|
$password = '123456';
|
|
$hash = $boxPassword->hashIt($password);
|
|
$this->assertIsString($hash);
|
|
$this->assertNotEmpty($hash);
|
|
|
|
$veryfied = $boxPassword->verify($password, $hash);
|
|
$this->assertIsBool($veryfied);
|
|
$this->assertTrue($veryfied);
|
|
|
|
$needRehashing = $boxPassword->needsRehash($hash);
|
|
$this->assertIsBool($needRehashing);
|
|
$this->assertFalse($needRehashing);
|
|
}
|
|
|
|
public function testNeedsRehashing()
|
|
{
|
|
$boxPassword = new Box_Password();
|
|
$password = '123456';
|
|
$hash = $boxPassword->hashIt($password);
|
|
$this->assertIsString($hash);
|
|
$this->assertNotEmpty($hash);
|
|
|
|
$newOptions = ['cost' => 15];
|
|
$boxPassword->setOptions($newOptions);
|
|
|
|
$needRehashing = $boxPassword->needsRehash($hash);
|
|
$this->assertIsBool($needRehashing);
|
|
$this->assertTrue($needRehashing);
|
|
}
|
|
}
|