Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120834147
AddTransactionTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
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
{
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestUser
(
'wallets-controller@kolabnow.com'
);
}
protected
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, Apr 24, 12:59 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18860875
Default Alt Text
AddTransactionTest.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline