Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F8199528
DomainTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
DomainTest.php
View Options
<?php
namespace
Tests\Unit\Methods
;
use
Tests\TestCase
;
class
DomainTest
extends
TestCase
{
protected
$domain
;
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
domain
=
new
\App\Domain
();
}
/**
* Test lower-casing namespace attribute.
*/
public
function
testSetNamespaceAttributeLowercases
()
{
$this
->
domain
=
new
\App\Domain
();
$this
->
domain
->
namespace
=
'UPPERCASE'
;
$this
->
assertTrue
(
$this
->
domain
->
namespace
===
'uppercase'
);
// @phpstan-ignore-line
}
/**
* Test setting the status to something invalid
*/
public
function
testSetStatusAttributeInvalid
()
{
$this
->
expectException
(
\Exception
::
class
);
$this
->
domain
->
status
=
123456
;
}
/**
* Test public domain.
*/
public
function
testSetStatusAttributeOnPublicDomain
()
{
$this
->
domain
->{
'type'
}
=
\App\Domain
::
TYPE_PUBLIC
;
$this
->
domain
->
status
=
115
;
$this
->
assertTrue
(
$this
->
domain
->
status
==
115
);
}
/**
* Test status mutations
*/
public
function
testSetStatusAttributeActiveMakesForNotNew
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_NEW
;
$this
->
assertTrue
(
$this
->
domain
->
isNew
());
$this
->
assertFalse
(
$this
->
domain
->
isActive
());
$this
->
domain
->
status
|=
\App\Domain
::
STATUS_ACTIVE
;
$this
->
assertFalse
(
$this
->
domain
->
isNew
());
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
}
/**
* Verify setting confirmed sets verified.
*/
public
function
testSetStatusAttributeConfirmedMakesForVerfied
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_CONFIRMED
;
$this
->
assertTrue
(
$this
->
domain
->
isConfirmed
());
$this
->
assertTrue
(
$this
->
domain
->
isVerified
());
}
/**
* Verify setting confirmed sets active.
*/
public
function
testSetStatusAttributeConfirmedMakesForActive
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_CONFIRMED
;
$this
->
assertTrue
(
$this
->
domain
->
isConfirmed
());
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
}
/**
* Verify setting deleted drops active.
*/
public
function
testSetStatusAttributeDeletedVoidsActive
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_ACTIVE
;
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
$this
->
assertFalse
(
$this
->
domain
->
isNew
());
$this
->
assertFalse
(
$this
->
domain
->
isDeleted
());
$this
->
domain
->
status
|=
\App\Domain
::
STATUS_DELETED
;
$this
->
assertFalse
(
$this
->
domain
->
isActive
());
$this
->
assertFalse
(
$this
->
domain
->
isNew
());
$this
->
assertTrue
(
$this
->
domain
->
isDeleted
());
}
/**
* Verify setting suspended drops active.
*/
public
function
testSetStatusAttributeSuspendedVoidsActive
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_ACTIVE
;
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
$this
->
assertFalse
(
$this
->
domain
->
isSuspended
());
$this
->
domain
->
status
|=
\App\Domain
::
STATUS_SUSPENDED
;
$this
->
assertFalse
(
$this
->
domain
->
isActive
());
$this
->
assertTrue
(
$this
->
domain
->
isSuspended
());
}
/**
* Verify we can suspend a suspended domain without disaster.
*
* This doesn't change anything to trigger a save.
*/
public
function
testSuspendForSuspendedDomain
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_ACTIVE
;
$this
->
domain
->
status
|=
\App\Domain
::
STATUS_SUSPENDED
;
$this
->
assertTrue
(
$this
->
domain
->
isSuspended
());
$this
->
assertFalse
(
$this
->
domain
->
isActive
());
$this
->
domain
->
suspend
();
$this
->
assertTrue
(
$this
->
domain
->
isSuspended
());
$this
->
assertFalse
(
$this
->
domain
->
isActive
());
}
/**
* Verify we can unsuspend an active (unsuspended) domain
*
* This doesn't change anything to trigger a save.
*/
public
function
testUnsuspendForActiveDomain
()
{
$this
->
domain
->
status
=
\App\Domain
::
STATUS_ACTIVE
;
$this
->
assertFalse
(
$this
->
domain
->
isSuspended
());
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
$this
->
domain
->
unsuspend
();
$this
->
assertFalse
(
$this
->
domain
->
isSuspended
());
$this
->
assertTrue
(
$this
->
domain
->
isActive
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jul 8, 11:27 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1052234
Default Alt Text
DomainTest.php (4 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment