Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120823487
UtilsTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
805 B
Referenced Files
None
Subscribers
None
UtilsTest.php
View Options
<?php
namespace
Tests\Unit\Auth
;
use
App\Auth\Utils
;
use
Carbon\Carbon
;
use
Tests\TestCase
;
class
UtilsTest
extends
TestCase
{
/**
* Test token creation and validation
*/
public
function
testTokenCreateAndValidate
():
void
{
$userid
=
'1234567890'
;
$token
=
Utils
::
tokenCreate
(
$userid
);
$this
->
assertTrue
(
strlen
(
$token
)
>
50
&&
strlen
(
$token
)
<
128
);
$this
->
assertTrue
(
preg_match
(
'|^[a-zA-Z0-9!+/]+$|'
,
$token
)
===
1
);
$this
->
assertSame
(
$userid
,
Utils
::
tokenValidate
(
$token
));
// Expired token
Carbon
::
setTestNow
(
Carbon
::
now
()->
addSeconds
(
11
));
$this
->
assertNull
(
Utils
::
tokenValidate
(
$token
));
// Invalid token
$this
->
assertNull
(
Utils
::
tokenValidate
(
'sdfsdfsfsdfsdfs!asd!sdfsdfsdfrwet'
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:06 AM (4 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18890619
Default Alt Text
UtilsTest.php (805 B)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline