<?php

namespace App\Tests\Service\Stripe;

use App\Service\Stripe\Client;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Stripe\Service\AccountService;
use Stripe\StripeClient;
use Vich\UploaderBundle\Storage\StorageInterface;
use Vich\UploaderBundle\Templating\Helper\UploaderHelper;

class ClientTest extends TestCase
{
    public function testCheckSuccess(): void
    {
        $em = $this->createStub(EntityManagerInterface::class);
        
        $storage = $this->createStub(StorageInterface::class);
        $uploaderHelper = new UploaderHelper($storage);
        
        $stripeClient = $this->createStub(StripeClient::class);

        $accountService = $this->createStub(AccountService::class);
        $accountService->method('all')->willReturn(new \Stripe\Collection());
        
        $stripeClient->method('__get')->willReturnMap([
            ['accounts', $accountService]
        ]);

        $client = new Client($em, $uploaderHelper, $stripeClient);
        
        $result = $client->check();
        
        $this->assertTrue($result['state']);
    }
}
