FixedRatesOperationsProviderTest.php in Currency 8.3
File
tests/src/Unit/Plugin/Currency/ExchangeRateProvider/FixedRatesOperationsProviderTest.php
View source
<?php
namespace Drupal\Tests\currency\Unit\Plugin\Currency\ExchangeRateProvider;
use Drupal\Core\Routing\RedirectDestinationInterface;
use Drupal\currency\Plugin\Currency\ExchangeRateProvider\FixedRatesOperationsProvider;
use Drupal\Tests\plugin\Unit\OperationsProviderTestTrait;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FixedRatesOperationsProviderTest extends UnitTestCase {
use OperationsProviderTestTrait;
protected $redirectDestination;
protected $stringTranslation;
protected $sut;
public function setUp() : void {
parent::setUp();
$this->redirectDestination = $this
->createMock(RedirectDestinationInterface::class);
$this->stringTranslation = $this
->getStringTranslationStub();
$this->sut = new FixedRatesOperationsProvider($this->stringTranslation, $this->redirectDestination);
}
function testCreate() {
$container = $this
->createMock(ContainerInterface::class);
$map = [
[
'redirect.destination',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->redirectDestination,
],
[
'string_translation',
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
$this->stringTranslation,
],
];
$container
->expects($this
->any())
->method('get')
->willReturnMap($map);
$sut_class = get_class($this->sut);
$sut = $sut_class::create($container);
$this
->assertInstanceOf($sut_class, $sut);
}
public function testGetOperations() {
$this
->assertOperationsLinks($this->sut
->getOperations($this
->randomMachineName()));
}
}