-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from burrelle/test/UnitTests
Add PHP Unit and basic Unit tests
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
vendor/ | ||
composer.lock | ||
.idea | ||
.idea | ||
.phpunit.result.cache |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use DivineOmega\LaravelPasswordExposedValidationRule\PasswordExposed; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PasswordExposedTest extends TestCase | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->passwordExposed = new PasswordExposed(); | ||
} | ||
|
||
/** @test */ | ||
public function defaultMessageIsReturned() | ||
{ | ||
$message = $this->passwordExposed->message(); | ||
$this->assertEquals('The :attribute has been exposed in a data breach.', $message); | ||
} | ||
|
||
/** @test */ | ||
public function customMessageCanBeSet() | ||
{ | ||
$customMessage = 'Custom message'; | ||
$passwordExposedObject = $this->passwordExposed->setMessage($customMessage); | ||
$setMessage = $passwordExposedObject->message(); | ||
$this->assertEquals($customMessage, $setMessage); | ||
} | ||
|
||
/** @test */ | ||
public function passwordFailsValidation() | ||
{ | ||
$password = 'password'; | ||
$passed = $this->passwordExposed->passes('password', $password); | ||
$this->assertFalse($passed); | ||
} | ||
|
||
/** @test */ | ||
public function passwordPassesValidation() | ||
{ | ||
$password = uniqid(); | ||
$passed = $this->passwordExposed->passes('password', $password); | ||
$this->assertTrue($passed); | ||
} | ||
} |