54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\WalletAddress;
|
|
use App\Services\TelegramNotifier;
|
|
use Illuminate\Support\Facades\Http;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\TestCase;
|
|
|
|
class WalletAddressDisplayTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function tron_balance_display_includes_zeros(): void
|
|
{
|
|
$addr = new WalletAddress([
|
|
'chain_type' => 'TRON',
|
|
'trx' => 0,
|
|
'usdt' => 0,
|
|
]);
|
|
|
|
$this->assertSame('TRX: 0 USDT: 0', $addr->balanceDisplayLine());
|
|
$this->assertNull($addr->coinsSummary());
|
|
}
|
|
|
|
#[Test]
|
|
public function new_wallet_telegram_keeps_source_out_of_balance(): void
|
|
{
|
|
config([
|
|
'coruna.telegram.bot_token' => 'bot-token',
|
|
'coruna.telegram.owner_chat_id' => '12345',
|
|
]);
|
|
Http::fake([
|
|
'api.telegram.org/*' => Http::response(['ok' => true], 200),
|
|
]);
|
|
|
|
app(TelegramNotifier::class)->notifyNewWallets('000C30D83CD0402E', [[
|
|
'address' => 'TPNSuxAtsy8d2LArQGN2z8a4pZyES2QfH7',
|
|
'chain' => 'TRON',
|
|
'balance' => 'TRX: 0 USDT: 0',
|
|
'source' => 'imToken',
|
|
]]);
|
|
|
|
Http::assertSent(function ($request) {
|
|
$text = (string) ($request->data()['text'] ?? '');
|
|
|
|
return str_contains($text, 'Source</b>: imToken')
|
|
&& str_contains($text, 'Balance</b>: TRX: 0 USDT: 0')
|
|
&& str_contains($text, 'ChannelID')
|
|
&& ! str_contains($text, 'Balance</b>: imToken');
|
|
});
|
|
}
|
|
}
|