Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117883194
PlanTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
PlanTest.php
View Options
<?php
namespace
Tests\Feature
;
use
App\Entitlement
;
use
App\Plan
;
use
App\Sku
;
use
Tests\TestCase
;
class
PlanTest
extends
TestCase
{
/**
* {@inheritDoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
Plan
::
where
(
'title'
,
'test-plan'
)->
delete
();
}
/**
* {@inheritDoc}
*/
public
function
tearDown
():
void
{
Plan
::
where
(
'title'
,
'test-plan'
)->
delete
();
parent
::
tearDown
();
}
/**
* Tests for plan attributes localization
*/
public
function
testPlanLocalization
():
void
{
$plan
=
Plan
::
create
([
'title'
=>
'test-plan'
,
'description'
=>
[
'en'
=>
'Plan-EN'
,
'de'
=>
'Plan-DE'
,
],
'name'
=>
'Test'
,
]);
$this
->
assertSame
(
'Plan-EN'
,
$plan
->
description
);
$this
->
assertSame
(
'Test'
,
$plan
->
name
);
$plan
->
save
();
$plan
=
Plan
::
where
(
'title'
,
'test-plan'
)->
first
();
$this
->
assertSame
(
'Plan-EN'
,
$plan
->
description
);
$this
->
assertSame
(
'Test'
,
$plan
->
name
);
$this
->
assertSame
(
'Plan-DE'
,
$plan
->
getTranslation
(
'description'
,
'de'
));
$this
->
assertSame
(
'Test'
,
$plan
->
getTranslation
(
'name'
,
'de'
));
$plan
->
setTranslation
(
'name'
,
'de'
,
'Prüfung'
)->
save
();
$this
->
assertSame
(
'Prüfung'
,
$plan
->
getTranslation
(
'name'
,
'de'
));
$this
->
assertSame
(
'Test'
,
$plan
->
getTranslation
(
'name'
,
'en'
));
$plan
=
Plan
::
where
(
'title'
,
'test-plan'
)->
first
();
$this
->
assertSame
(
'Prüfung'
,
$plan
->
getTranslation
(
'name'
,
'de'
));
$this
->
assertSame
(
'Test'
,
$plan
->
getTranslation
(
'name'
,
'en'
));
// TODO: Test system locale change
}
/**
* Tests for Plan::hasDomain()
*/
public
function
testHasDomain
():
void
{
$plan
=
Plan
::
where
(
'title'
,
'individual'
)->
first
();
$this
->
assertTrue
(
$plan
->
hasDomain
()
===
false
);
$plan
=
Plan
::
where
(
'title'
,
'group'
)->
first
();
$this
->
assertTrue
(
$plan
->
hasDomain
()
===
true
);
}
/**
* Test for a plan's cost.
*/
public
function
testCost
():
void
{
$plan
=
Plan
::
where
(
'title'
,
'individual'
)->
first
();
$package_costs
=
0
;
foreach
(
$plan
->
packages
as
$package
)
{
$package_costs
+=
$package
->
cost
();
}
$this
->
assertTrue
(
$package_costs
==
999
,
"The total costs of all packages for this plan is not 9.99"
);
$this
->
assertTrue
(
$plan
->
cost
()
==
999
,
"The total costs for this plan is not 9.99"
);
$this
->
assertTrue
(
$plan
->
cost
()
==
$package_costs
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Apr 6, 12:57 AM (4 d, 23 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d2/07/afcbbfbd30056059fee8619e6c7e
Default Alt Text
PlanTest.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline