-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to customize how invite codes are generated (#44)
* Allow to customize how invite codes are generated * Remove unrelated feature * Fix docblocks * wip
- Loading branch information
1 parent
7a71ecf
commit b54a2a9
Showing
4 changed files
with
61 additions
and
13 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
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
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 |
---|---|---|
|
@@ -3,9 +3,11 @@ | |
namespace Junges\InviteCodes\Tests; | ||
|
||
use Illuminate\Support\Facades\Event; | ||
use Illuminate\Support\Str; | ||
use Junges\InviteCodes\Contracts\InviteContract; | ||
use Junges\InviteCodes\Events\InviteRedeemedEvent; | ||
use Junges\InviteCodes\Facades\InviteCodes; | ||
use Junges\InviteCodes\Models\Invite; | ||
|
||
class FactoryTest extends TestCase | ||
{ | ||
|
@@ -42,4 +44,17 @@ public function test_macro(): void | |
$this->assertInstanceOf(InviteContract::class, $invite); | ||
$this->assertTrue($invite->usageRestrictedToEmail('[email protected]')); | ||
} | ||
|
||
public function test_it_can_customize_how_invite_code_is_created(): void | ||
{ | ||
InviteCodes::createInviteCodeUsing(static function () { | ||
return 'PREFIX-12345'; | ||
}); | ||
|
||
$invite = InviteCodes::create()->save(); | ||
|
||
$this->assertSame('PREFIX-12345', $invite->code); | ||
|
||
InviteCodes::createInviteCodeUsing(null); | ||
} | ||
} |