Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485043
SetDiscountTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SetDiscountTest.php
View Options
<?php
namespace
Tests\Feature\Console\Wallet
;
use
Tests\TestCase
;
class
SetDiscountTest
extends
TestCase
{
/**
* {@inheritDoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestUser
(
'wallets-controller@kolabnow.com'
);
}
/**
* {@inheritDoc}
*/
public
function
tearDown
():
void
{
$this
->
deleteTestUser
(
'wallets-controller@kolabnow.com'
);
parent
::
tearDown
();
}
/**
* Test command run for a specified wallet
*/
public
function
testHandle
():
void
{
$user
=
$this
->
getTestUser
(
'wallets-controller@kolabnow.com'
);
$package
=
\App\Package
::
where
(
'title'
,
'kolab'
)->
first
();
$user
->
assignPackage
(
$package
);
$wallet
=
$user
->
wallets
()->
first
();
$discount
=
\App\Discount
::
withObjectTenantContext
(
$user
)->
where
(
'discount'
,
100
)->
first
();
// Invalid wallet id
$code
=
\Artisan
::
call
(
"wallet:set-discount 123 123"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
"Wallet not found."
,
$output
);
// Invalid discount id
$code
=
\Artisan
::
call
(
"wallet:set-discount {$wallet->id} 123"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
"Discount not found."
,
$output
);
// Assign a discount
$code
=
\Artisan
::
call
(
"wallet:set-discount {$wallet->id} {$discount->id}"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
""
,
$output
);
$wallet
->
refresh
();
$this
->
assertSame
(
$discount
->
id
,
$wallet
->
discount_id
);
// Remove the discount
$code
=
\Artisan
::
call
(
"wallet:set-discount {$wallet->id} 0"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
""
,
$output
);
$wallet
->
refresh
();
$this
->
assertNull
(
$wallet
->
discount_id
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Nov 20, 6:02 PM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
385815
Default Alt Text
SetDiscountTest.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment