<?php

namespace Tests\Unit\Framework;

use Openguru\OpenCartFramework\Translator\Translator;
use Tests\TestCase;

class TranslatorTest extends TestCase
{
    public function testBasicTranslate(): void
    {
        $translator = new Translator('ru', ['foo' => 'bar']);

        $this->assertEquals('bar', $translator->translate('foo'));
    }

    public function testTranslateWithParams(): void
    {
        $translator = new Translator('ru', [
            'example' => '{placeholder_1} foo {placeholder_2} bar {placeholder_3}',
        ]);

        $placeholders = ['placeholder_1' => 'a', 'placeholder_2' => 'b', 'placeholder_3' => 'c'];
        $expected = 'a foo b bar c';

        $this->assertEquals(
            $expected,
            $translator->translate('example', $placeholders)
        );
    }
}
