Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485164
AddTransactionTest.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
AddTransactionTest.php
View Options
<?php
namespace
Tests\Feature\Console\Wallet
;
use
Tests\TestCase
;
class
AddTransactionTest
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'
);
$wallet
=
$user
->
wallets
()->
first
();
// Invalid wallet id
$code
=
\Artisan
::
call
(
"wallet:add-transaction 123 100"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
"Wallet not found."
,
$output
);
// Add credit
$code
=
\Artisan
::
call
(
"wallet:add-transaction {$wallet->id} 100"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
""
,
$output
);
$wallet
->
refresh
();
$this
->
assertSame
(
100
,
$wallet
->
balance
);
// Add debit with a transaction description
// Note: The double-dash trick to make it working with a negative number input
$code
=
\Artisan
::
call
(
"wallet:add-transaction --message=debit -- {$wallet->id} -100"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
""
,
$output
);
$wallet
->
refresh
();
$this
->
assertSame
(
0
,
$wallet
->
balance
);
$this
->
assertCount
(
1
,
$wallet
->
transactions
()->
where
(
'description'
,
'debit'
)->
get
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 5:19 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387382
Default Alt Text
AddTransactionTest.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment