You are here

public function AmountTest::setUp in Currency 8.3

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/views/field/AmountTest.php, line 103

Class

AmountTest
@coversDefaultClass \Drupal\currency\Plugin\views\field\Amount

Namespace

Drupal\Tests\currency\Unit\Plugin\views\field

Code

public function setUp() : void {
  $configuration = [];
  $plugin_id = $this
    ->randomMachineName();
  $this->pluginDefinition = [
    'group' => $this
      ->randomMachineName(),
    'title' => $this
      ->randomMachineName(),
  ];
  $this->configFactory = $this
    ->createMock(ConfigFactoryInterface::class);
  $this->currencyStorage = $this
    ->createMock(EntityStorageInterface::class);
  $this->moduleHandler = $this
    ->createMock(ModuleHandlerInterface::class);
  $this->renderer = $this
    ->createMock(RendererInterface::class);
  $this->stringTranslation = $this
    ->getStringTranslationStub();
  $this->viewsDisplayHandler = $this
    ->getMockBuilder(DisplayPluginBase::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->viewsQuery = $this
    ->getMockBuilder(Sql::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->viewsViewExecutable = $this
    ->getMockBuilder(ViewExecutable::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->viewsViewExecutable->display_handler = $this->viewsDisplayHandler;
  $this->viewsViewExecutable->query = $this->viewsQuery;
  $container = new ContainerBuilder();
  $container
    ->set('config.factory', $this->configFactory);
  $container
    ->set('renderer', $this->renderer);
  \Drupal::setContainer($container);
  $this->sut = new Amount($configuration, $plugin_id, $this->pluginDefinition, $this->stringTranslation, $this->moduleHandler, $this->renderer, $this->currencyStorage);
  $this->sut
    ->init($this->viewsViewExecutable, $this->viewsDisplayHandler);
}