Page MenuHomePhorge

SignupCodeTest.php
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

SignupCodeTest.php

<?php
namespace Tests\Feature;
use App\SignupCode;
use Carbon\Carbon;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class SignupCodeTest extends TestCase
{
/**
* Test SignupCode creation
*
* @return void
*/
public function testSignupCodeCreate()
{
$data = [
'data' => [
'email' => 'User@email.org',
'name' => 'User Name',
]
];
$now = Carbon::now();
$code = SignupCode::create($data);
$this->assertFalse($code->isExpired());
$this->assertTrue(strlen($code->code) === SignupCode::CODE_LENGTH);
$this->assertTrue(
strlen($code->short_code) === env(
'VERIFICATION_CODE_LENGTH',
SignupCode::SHORTCODE_LENGTH
)
);
$this->assertSame($data['data'], $code->data);
$this->assertInstanceOf(Carbon::class, $code->expires_at);
$this->assertSame(
env('SIGNUP_CODE_EXPIRY', SignupCode::CODE_EXP_HOURS),
$code->expires_at->diffInHours($now) + 1
);
$inst = SignupCode::find($code->code);
$this->assertInstanceOf(SignupCode::class, $inst);
$this->assertSame($inst->code, $code->code);
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Apr 6, 12:47 AM (5 d, 14 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c5/69/d2b84ec5aae85553ae3afb319544
Default Alt Text
SignupCodeTest.php (1 KB)

Event Timeline