. */ declare(strict_types=1); namespace Tests\Unit\Transformers; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Transformers\CurrencyTransformer; use Log; use Symfony\Component\HttpFoundation\ParameterBag; use Tests\TestCase; /** * Class CurrencyTransformerTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class CurrencyTransformerTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * Basic coverage * * @covers \FireflyIII\Transformers\CurrencyTransformer */ public function testBasic(): void { // mocks and prep: $parameters = new ParameterBag; $currency = $this->getEuro(); $transformer = app(CurrencyTransformer::class); $transformer->setParameters($parameters); // action $result = $transformer->transform($currency); $this->assertEquals($currency->code, $result['code']); $this->assertFalse($result['default']); } /** * Basic coverage with default currency * * @covers \FireflyIII\Transformers\CurrencyTransformer */ public function testDefaultCurrency(): void { // mocks and prep: $parameters = new ParameterBag; $currency = $this->getEuro(); $parameters->set('defaultCurrency', $currency); $transformer = app(CurrencyTransformer::class); $transformer->setParameters($parameters); // action $result = $transformer->transform($currency); $this->assertEquals($currency->code, $result['code']); $this->assertTrue($result['default']); } }