Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120838090
SkusTest.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
SkusTest.php
View Options
<?php
namespace
Tests\Feature\Controller
;
use
App\Http\Controllers\API\SkusController
;
use
App\Sku
;
use
Tests\TestCase
;
class
SkusTest
extends
TestCase
{
/**
* Test fetching SKUs list
*/
public
function
testIndex
():
void
{
// Unauth access not allowed
$response
=
$this
->
get
(
"api/v4/skus"
);
$response
->
assertStatus
(
401
);
$user
=
$this
->
getTestUser
(
'john@kolab.org'
);
$domain_sku
=
Sku
::
where
(
'title'
,
'domain'
)->
first
();
$response
=
$this
->
actingAs
(
$user
)->
get
(
"api/v4/skus"
);
$response
->
assertStatus
(
200
);
$json
=
$response
->
json
();
$this
->
assertCount
(
7
,
$json
);
$this
->
assertSame
(
$domain_sku
->
id
,
$json
[
0
][
'id'
]);
$this
->
assertSame
(
$domain_sku
->
title
,
$json
[
0
][
'title'
]);
$this
->
assertSame
(
$domain_sku
->
name
,
$json
[
0
][
'name'
]);
$this
->
assertSame
(
$domain_sku
->
description
,
$json
[
0
][
'description'
]);
$this
->
assertSame
(
$domain_sku
->
cost
,
$json
[
0
][
'cost'
]);
$this
->
assertSame
(
$domain_sku
->
units_free
,
$json
[
0
][
'units_free'
]);
$this
->
assertSame
(
$domain_sku
->
period
,
$json
[
0
][
'period'
]);
$this
->
assertSame
(
$domain_sku
->
active
,
$json
[
0
][
'active'
]);
$this
->
assertSame
(
'domain'
,
$json
[
0
][
'type'
]);
$this
->
assertSame
(
'domain'
,
$json
[
0
][
'handler'
]);
}
/**
* Test for SkusController::skuElement()
*/
public
function
testSkuElement
():
void
{
$sku
=
Sku
::
where
(
'title'
,
'storage'
)->
first
();
$result
=
$this
->
invokeMethod
(
new
SkusController
(),
'skuElement'
,
[
$sku
]);
$this
->
assertSame
(
$sku
->
id
,
$result
[
'id'
]);
$this
->
assertSame
(
$sku
->
title
,
$result
[
'title'
]);
$this
->
assertSame
(
$sku
->
name
,
$result
[
'name'
]);
$this
->
assertSame
(
$sku
->
description
,
$result
[
'description'
]);
$this
->
assertSame
(
$sku
->
cost
,
$result
[
'cost'
]);
$this
->
assertSame
(
$sku
->
units_free
,
$result
[
'units_free'
]);
$this
->
assertSame
(
$sku
->
period
,
$result
[
'period'
]);
$this
->
assertSame
(
$sku
->
active
,
$result
[
'active'
]);
$this
->
assertSame
(
'user'
,
$result
[
'type'
]);
$this
->
assertSame
(
'storage'
,
$result
[
'handler'
]);
$this
->
assertSame
(
$sku
->
units_free
,
$result
[
'range'
][
'min'
]);
$this
->
assertSame
(
$sku
->
handler_class
::
MAX_ITEMS
,
$result
[
'range'
][
'max'
]);
$this
->
assertSame
(
$sku
->
handler_class
::
ITEM_UNIT
,
$result
[
'range'
][
'unit'
]);
$this
->
assertTrue
(
$result
[
'readonly'
]);
$this
->
assertTrue
(
$result
[
'enabled'
]);
// Test all SKU types
$this
->
markTestIncomplete
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:54 PM (5 d, 9 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
26/45/56ff218f3e82bcb8b487e5bc6c9e
Default Alt Text
SkusTest.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline