File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 11vendor /
22composer.lock
3- .idea
3+ .idea
4+ .phpunit.result.cache
Original file line number Diff line number Diff line change 1818 "psr-4" : {
1919 "DivineOmega\\ LaravelPasswordExposedValidationRule\\ " : " ./src/"
2020 }
21+ },
22+ "autoload-dev" : {
23+ "psr-4" : {
24+ "Tests\\ " : " tests/"
25+ }
26+ },
27+ "require-dev" : {
28+ "phpunit/phpunit" : " ^8.0"
2129 }
2230}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Unit ;
4+
5+ use DivineOmega \LaravelPasswordExposedValidationRule \PasswordExposed ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ class PasswordExposedTest extends TestCase
9+ {
10+ public function setUp () : void
11+ {
12+ $ this ->passwordExposed = new PasswordExposed ();
13+ }
14+
15+ /** @test */
16+ public function defaultMessageIsReturned ()
17+ {
18+ $ message = $ this ->passwordExposed ->message ();
19+ $ this ->assertEquals ('The :attribute has been exposed in a data breach. ' , $ message );
20+ }
21+
22+ /** @test */
23+ public function customMessageCanBeSet ()
24+ {
25+ $ customMessage = 'Custom message ' ;
26+ $ passwordExposedObject = $ this ->passwordExposed ->setMessage ($ customMessage );
27+ $ setMessage = $ passwordExposedObject ->message ();
28+ $ this ->assertEquals ($ customMessage , $ setMessage );
29+ }
30+
31+ /** @test */
32+ public function passwordFailsValidation ()
33+ {
34+ $ password = 'password ' ;
35+ $ passed = $ this ->passwordExposed ->passes ('password ' , $ password );
36+ $ this ->assertFalse ($ passed );
37+ }
38+
39+ /** @test */
40+ public function passwordPassesValidation ()
41+ {
42+ $ password = uniqid ();
43+ $ passed = $ this ->passwordExposed ->passes ('password ' , $ password );
44+ $ this ->assertTrue ($ passed );
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments