Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

jcergolj/laravellte

216 stars
1 code files
View jcergolj/laravellte on GitHub

tests/Unit/Rules/PasswordRuleTest.php

Open in GitHub
use App\Rules\PasswordRule;
use Tests\HasPwnedMock;
use Tests\TestCase;
 
class PasswordRuleTest extends TestCase
{
use HasPwnedMock;
 
public function setUp() : void
{
parent::setUp();
 
$this->mockPwned();
}
 
/** @test */
public function validation_passes()
{
$rule = new PasswordRule('password');
 
$this->assertTrue($rule->passes('password', 'password'));
}
 
/** @test */
public function password_is_required()
{
$rule = new PasswordRule('');
 
$this->assertFalse($rule->passes('password', ''));
}
 
/** @test */
public function password_must_be_at_least_8_char_in_length()
{
$rule = new PasswordRule('1234567');
 
$this->assertFalse($rule->passes('password', '1234567'));
}
 
/** @test */
public function password_must_be_confirmed()
{
$rule = new PasswordRule('password-not-confirmed');
 
$this->assertFalse($rule->passes('password', 'password'));
}
 
/** @test */
public function password_must_not_be_pwned()
{
$this->mockPwned(false);
 
$rule = new PasswordRule('password-not-confirmed');
 
$this->assertFalse($rule->passes('password', 'password'));
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.